POCO链接错误,OS X 10.11.2上体系结构x86_64的未定义符号

POCO Linking error, undefined symbols for architecture x86_64 on OS X 10.11.2

本文关键字:x86 体系结构 符号 未定义 错误 链接 OS POCO      更新时间:2023-10-16

我使用Homebrew安装了POCO
有人建议使用stdlibc++,但当我这样做时,除了POCO链接错误之外,我还会收到一堆std链接错误
我还尝试使用Homebrew的gcc中的g++而不是苹果的g++,但这会产生同样的错误。

生成文件

CXX=g++
RM=rm -f
CXXFLAGS=-std=c++11 -Wall -O3 -I/usr/local/opt/openssl/include -I/usr/local/Cellar/poco/1.6.1/include
LDFLAGS=-L/usr/local/opt/openssl/lib -L/usr/local/Cellar/poco/1.6.1/lib
LDLIBS=-lPocoNet -lPocoFoundation
SRCS=eml.cc
OBJS=$(subst .cc,.o,$(SRCS))
all: eml
eml: $(OBJS)
    $(CXX) $(CXXFLAGS) $(LDFLAGS) -o eml $(OBJS) $(LDLIBS)
%.o: %.c
    $(CXX) $(CXXFLAGS) -c $< -o $@
clean:
    $(RM) eml $(OBJS)

错误

g++ -std=c++11 -stdlib=libc++ -Wall -O3 -I/usr/local/opt/openssl/include -I/usr/local/Cellar/poco/1.6.1/include -L/usr/local/opt/openssl/lib -L/usr/local/Cellar/poco/1.6.1/lib -o eml eml.o -lPocoNet -lPocoFoundation -lcrypto
Undefined symbols for architecture x86_64:
  "Poco::Net::SSLManager::initializeClient(Poco::SharedPtr<Poco::Net::PrivateKeyPassphraseHandler, Poco::ReferenceCounter, Poco::ReleasePolicy<Poco::Net::PrivateKeyPassphraseHandler> >, Poco::SharedPtr<Poco::Net::InvalidCertificateHandler, Poco::ReferenceCounter, Poco::ReleasePolicy<Poco::Net::InvalidCertificateHandler> >, Poco::AutoPtr<Poco::Net::Context>)", referenced from:
      _main in eml.o
  "Poco::Net::SSLManager::instance()", referenced from:
      _main in eml.o
  "Poco::Net::initializeSSL()", referenced from:
      _main in eml.o
  "Poco::Net::uninitializeSSL()", referenced from:
      _main in eml.o
  "Poco::Net::SecureStreamSocket::SecureStreamSocket(Poco::Net::SocketAddress const&)", referenced from:
      _main in eml.o
  "Poco::Net::SecureStreamSocket::~SecureStreamSocket()", referenced from:
      _main in eml.o
  "Poco::Net::AcceptCertificateHandler::AcceptCertificateHandler(bool)", referenced from:
      _main in eml.o
  "Poco::Net::Context::Context(Poco::Net::Context::Usage, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, Poco::Net::Context::VerificationMode, int, bool, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&)", referenced from:
      _main in eml.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make: *** [eml] Error 1

您没有链接所有必需的库。所有未解决的在CCD_ 1中定义符号。若要安装此库,必须生成POCO库的完整版本,而不是基本版本。

如果你查阅任何POCO API的文档,它会告诉你需要链接的库,例如CCD_ 2。