clang-3.9不与用abi :: cxx11编译的poco lib链接

时间:2017-12-14 17:48:22

标签: c++ clang++ poco-libraries libstdc++

我在Fedora上并尝试使用我系统上安装的Poco库编译和链接项目。我用GCC 6编译和链接我的项目时一切正常。但是,当我使用clang-3.9编译和链接我的项目时出现链接错误:

 undefined reference to `Poco::JSON::Object::operator Poco::Dynamic::Struct<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > > const&() const'

我检查了libPocoJSON.so中的符号,其中包含以下内容:

0000000000022d80 T Poco::JSON::Object::operator Poco::Dynamic::Struct<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > > const&[abi:cxx11]() const

所以,问题在于,当我使用clang进行编译时,它正在寻找库中不存在的符号。

我尝试向我的程序提供-D_GLIBCXX_USE_CXX11_ABI=1,希望它会强制它查找带有abi:cxx11标记的符号,但它没有帮助。我现在很困惑,这是POCO问题,还是clang++问题?

编辑: 输出clang -v

clang version 3.9.1 (tags/RELEASE_391/final)
Target: x86_64-unknown-linux-gnu
Thread model: posix
InstalledDir: /usr/bin
Found candidate GCC installation: /usr/bin/../lib/gcc/x86_64-redhat-linux/6.4.1
Found candidate GCC installation: /usr/lib/gcc/x86_64-redhat-linux/6.4.1
Selected GCC installation: /usr/bin/../lib/gcc/x86_64-redhat-linux/6.4.1
Candidate multilib: .;@m64
Candidate multilib: 32;@m32
Selected multilib: .;@m64

EDIT2: 编译和链接命令:

/bin/sh ../libtool  --tag=CXX   --mode=link clang++  -DTDOC=\"../test/data\" -I../common -I../net -I../wsd -I../kit -D_GLIBCXX_USE_CXX11_ABI=1 -std=c++11 -pthread -module -rpath /dummy -lz  -o test test-TileQueueTests.o test-WhiteBoxTests.o test-DeltaTests.o ../common/test-FileUtil.o ../common/test-SigUtil.o ../common/test-IoUtil.o ../common/test-Log.o ../common/test-Protocol.o ../common/test-Session.o ../common/test-Util.o ../common/test-MessageQueue.o ../kit/test-Kit.o ../wsd/test-Auth.o ../wsd/test-TileCache.o ../wsd/test-TestStubs.o ../common/test-Unit.o ../net/test-Socket.o test-TileCacheTests.o test-integration-http-server.o test-httpwstest.o test-httpcrashtest.o test-httpwserror.o test-test.o -lcppunit -lcap -lpng -ldl  -lPocoNet -lPocoUtil -lPocoJSON -lPocoFoundation -lPocoXML -lPocoNetSSL -lPocoCrypto -lpcre

libtool: link: clang++ -DTDOC=\"../test/data\" -I../common -I../net -I../wsd -I../kit -D_GLIBCXX_USE_CXX11_ABI=1 -std=c++11 -pthread -o test test-TileQueueTests.o test-WhiteBoxTests.o test-DeltaTests.o ../common/test-FileUtil.o ../common/test-SigUtil.o ../common/test-IoUtil.o ../common/test-Log.o ../common/test-Protocol.o ../common/test-Session.o ../common/test-Util.o ../common/test-MessageQueue.o ../kit/test-Kit.o ../wsd/test-Auth.o ../wsd/test-TileCache.o ../wsd/test-TestStubs.o ../common/test-Unit.o ../net/test-Socket.o test-TileCacheTests.o test-integration-http-server.o test-httpwstest.o test-httpcrashtest.o test-httpwserror.o test-test.o  -lz -lcppunit -lcap -lpng -ldl -lPocoNet -lPocoUtil -lPocoJSON -lPocoFoundation -lPocoXML -lPocoNetSSL -lPocoCrypto -lpcre -pthread -Wl,-rpath -Wl,/dummy

EDIT3: 链接器邀请:

 "/usr/bin/ld" --hash-style=gnu --no-add-needed --build-id --eh-frame-hdr -m elf_x86_64 -dynamic-linker /lib64/ld-linux-x86-64.so.2 -o test /usr/bin/../lib/gcc/x86_64-redhat-linux/6.4.1/../../../../lib64/crt1.o /usr/bin/../lib/gcc/x86_64-redhat-linux/6.4.1/../../../../lib64/crti.o /usr/bin/../lib/gcc/x86_64-redhat-linux/6.4.1/crtbegin.o -L/usr/bin/../lib/gcc/x86_64-redhat-linux/6.4.1 -L/usr/bin/../lib/gcc/x86_64-redhat-linux/6.4.1/../../../../lib64 -L/usr/bin/../lib64 -L/lib/../lib64 -L/usr/lib/../lib64 -L/usr/bin/../lib/gcc/x86_64-redhat-linux/6.4.1/../../.. -L/usr/bin/../lib -L/lib -L/usr/lib test-TileQueueTests.o test-WhiteBoxTests.o test-DeltaTests.o ../common/test-FileUtil.o ../common/test-SigUtil.o ../common/test-IoUtil.o ../common/test-Log.o ../common/test-Protocol.o ../common/test-Session.o ../common/test-Util.o ../common/test-MessageQueue.o ../kit/test-Kit.o ../wsd/test-Auth.o ../wsd/test-TileCache.o ../wsd/test-TestStubs.o ../common/test-Unit.o ../net/test-Socket.o test-TileCacheTests.o test-integration-http-server.o test-httpwstest.o test-httpcrashtest.o test-httpwserror.o test-test.o -lz -lcppunit -lcap -lpng -ldl -lPocoNet -lPocoUtil -lPocoJSON -lPocoFoundation -lPocoXML -lPocoNetSSL -lPocoCrypto -lpcre -rpath /dummy -lstdc++ -lm -lgcc_s -lgcc -lpthread -lc -lgcc_s -lgcc /usr/bin/../lib/gcc/x86_64-redhat-linux/6.4.1/crtend.o /usr/bin/../lib/gcc/x86_64-redhat-linux/6.4.1/../../../../lib64/crtn.o

0 个答案:

没有答案