mardi 2 novembre 2021

C++ failing to link on a preprocessor directive

I want to check that my '#include' works but it fails to link with a specific file in the poco library. I call g++ -std=c++11 cry.cpp to compile a file with a empty main and the follow preprocessor directive

#include <Poco/Net/HTTPClientSession.h>

It gives the error message

Undefined symbols for architecture x86_64:
  "Poco::Net::Impl::SocketAddressImpl::~SocketAddressImpl()", referenced from:
      Poco::Net::Impl::IPv4SocketAddressImpl::~IPv4SocketAddressImpl() in cry-0a8f88.o
      Poco::Net::Impl::IPv6SocketAddressImpl::~IPv6SocketAddressImpl() in cry-0a8f88.o
  "Poco::Net::IPAddress::IPAddress(void const*, unsigned int)", referenced from:
      Poco::Net::Impl::IPv4SocketAddressImpl::host() const in cry-0a8f88.o
  "Poco::Net::IPAddress::IPAddress(void const*, unsigned int, unsigned int)", referenced from:
      Poco::Net::Impl::IPv6SocketAddressImpl::host() const in cry-0a8f88.o
  "Poco::Net::Impl::IPv4SocketAddressImpl::toString() const", referenced from:
      vtable for Poco::Net::Impl::IPv4SocketAddressImpl in cry-0a8f88.o
  "Poco::Net::Impl::IPv6SocketAddressImpl::toString() const", referenced from:
      vtable for Poco::Net::Impl::IPv6SocketAddressImpl in cry-0a8f88.o
  "typeinfo for Poco::Net::Impl::SocketAddressImpl", referenced from:
      typeinfo for Poco::Net::Impl::IPv4SocketAddressImpl in cry-0a8f88.o
      typeinfo for Poco::Net::Impl::IPv6SocketAddressImpl in cry-0a8f88.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)

I have tried loading other files from the library such as

#include <Poco/Net/HTTPRequest.h>
#include <Poco/Net/HTTPResponse.h>
#include <Poco/Net/HTMLForm.h>
#include <Poco/URI.h>
#include <Poco/Path.h>

and they all allow me to compile and execute the code without errors.

Aucun commentaire:

Enregistrer un commentaire