How can I statically link a C++ library to a C application in OSX? -
i've looked through other similar questions topic, , think there's osx-specific i'm missing.
i'm trying statically link basho's fork of leveldb c application (since packaged versions of leveldb use google's mainline). using c++ linker , adding -lc++ command line, still flooded errors missing c++ stl symbols such as:
"std::string::_rep::_m_destroy(std::allocator const&)", referenced from: _leveldb_open in libleveldb.a(c.o)
the strange thing is, know have c++ bits enabled right because i'm linking libsnappy, , before added link directive there unresolved libsnappy symbols (obviously) cleared up.
as far know, have latest version of xcode & rest of compiler chain. libleveldb compiled using same toolchain regular application. here's command line i'm trying:
/applications/xcode.app/contents/developer/toolchains/xcodedefault.xctoolchain/usr/bin/c++ -g -wl,-search_paths_first -wl,-headerpad_max_install_names cmakefiles/get_rid_status.dir/get_rid_status.c.o -o get_rid_status /usr/local/lib/libdb.a /usr/lib/libssl.dylib /usr/lib/libcrypto.dylib /usr/lib/libaprutil-1.dylib /usr/lib/libapr-1.dylib -lpthread -ldl -lm -lz leveldb/libleveldb.a /usr/local/lib/libsnappy.dylib -lc++
i'm linking c++ linker , adding c++ standard library -lc++ no avail.
update found correct answer, can found below. kudos users told me right etiquette when answered own question here.
turns out, leveldb adds linker flags didn't notice @ first. culprit -mmacosx-version-min=10.8
. adding flag link step of c application got line up.
Comments
Post a Comment