XCode无法编译Poco项目,未定义的符号

时间:2016-04-30 12:26:00

标签: c++ xcode c++11 linker poco-libraries

我一直在用C ++寻找合适的HTTP解析器,今天我发现Poco既支持解析HTTP请求,也支持设置服务器,还设置了HTTPS服务器以及其他很酷的功能,我很渴望开始使用它。

我在编译一个小例子时遇到了问题,该项目被设置为stdc ++ 11项目,我将头文件和库搜索路径设置为/ usr / local / include和/ usr / local / lib并按照以下顺序链接了其他链接器标志中的库本身“-lPocoNet -lPocoUtil -lPocoFoundation -lPocoXML -lPocoJSON”,其顺序似乎并不重要。

代码本身不会在XCode中抛出任何错误,只是当我尝试编译它时我得到了这些引用错误,我通过将库添加到Other Linker Flags选项中修复了38个其他错误但是这两个错误不会消失。

我得到的错误如下

Ld /Users/zezioen/Library/Developer/Xcode/DerivedData/NitroServer-gpnzdaqmezqcauegsmrabobsxotk/Build/Products/Debug/NitroServer normal x86_64
cd /Users/zezioen/stack/Projecten/CPP/NitroServer
export MACOSX_DEPLOYMENT_TARGET=10.11
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang++ -arch x86_64 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.11.sdk -L/Users/zezioen/Library/Developer/Xcode/DerivedData/NitroServer-gpnzdaqmezqcauegsmrabobsxotk/Build/Products/Debug -L/Users/zezioen/stack/Projecten/CPP/NitroServer/lib -L/usr/local/lib -F/Users/zezioen/Library/Developer/Xcode/DerivedData/NitroServer-gpnzdaqmezqcauegsmrabobsxotk/Build/Products/Debug -F/Users/zezioen/stack/Projecten/CPP/NitroServer/lib -filelist /Users/zezioen/Library/Developer/Xcode/DerivedData/NitroServer-gpnzdaqmezqcauegsmrabobsxotk/Build/Intermediates/NitroServer.build/Debug/NitroServer.build/Objects-normal/x86_64/NitroServer.LinkFileList -mmacosx-version-min=10.11 -Xlinker -no_deduplicate -lPocoNet -lPocoUtil -lPocoFoundation -lPocoXML -lPocoJSON -stdlib=libstdc++ -Xlinker -dependency_info -Xlinker /Users/zezioen/Library/Developer/Xcode/DerivedData/NitroServer-gpnzdaqmezqcauegsmrabobsxotk/Build/Intermediates/NitroServer.build/Debug/NitroServer.build/Objects-normal/x86_64/NitroServer_dependency_info.dat -o /Users/zezioen/Library/Developer/Xcode/DerivedData/NitroServer-gpnzdaqmezqcauegsmrabobsxotk/Build/Products/Debug/NitroServer

Undefined symbols for architecture x86_64:
  "Poco::Net::HTTPMessage::setContentType(std::string const&)", referenced from:
      MyRequestHandler::handleRequest(Poco::Net::HTTPServerRequest&, Poco::Net::HTTPServerResponse&) in main.o
  "Poco::Util::Application::handleOption(std::string const&, std::string const&)", referenced from:
      vtable for MyServerApp in main.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)

为了让项目构建,我该怎么办?

1 个答案:

答案 0 :(得分:0)

已解决here - POCO与libc++相关联,应用程序与libstdc ++链接。