Arman
Arman

Reputation: 1084

Poco C++ library on OSX 10.8.2: Undefined symbols for architecture x86_64

I'm trying to use Poco C++ library to do the simple http requests in C++ on Mac OS X 10.8.2. I installed Poco, copy-pasted the http_request.cc code from this tutorial, ran it with 'g++ -o http_get http_get.cc -lPocoNet', but got:

Undefined symbols for architecture x86_64:
  "Poco::StreamCopier::copyStream(std::basic_istream<char, std::char_traits<char> >&, std::basic_ostream<char, std::char_traits<char> >&, unsigned long)", referenced from:
      _main in ccKuZb1g.o
  "Poco::URI::URI(char const*)", referenced from:
      _main in ccKuZb1g.o
  "Poco::URI::~URI()", referenced from:
      _main in ccKuZb1g.o
  "Poco::URI::getPathAndQuery() const", referenced from:
      _main in ccKuZb1g.o
  "Poco::URI::getPort() const", referenced from:
      _main in ccKuZb1g.o
  "Poco::Exception::displayText() const", referenced from:
      _main in ccKuZb1g.o
  "typeinfo for Poco::Exception", referenced from:
      GCC_except_table1 in ccKuZb1g.o
ld: symbol(s) not found for architecture x86_64
collect2: ld returned 1 exit status

Have been struggling with this for couple of hours. Any idea how to fix this? Thanks in advance!

Upvotes: 1

Views: 1976

Answers (2)

Anya Shenanigans
Anya Shenanigans

Reputation: 94829

the Poco::URI, Poco::StreamCopier classes are in the PocoFoundation library, so you will need to link to that library also.

g++ -o http_get http_get.cc -lPocoNet -lPocoFoundation

Upvotes: 3

bobestm
bobestm

Reputation: 1334

You don't appear to have specified the include path for the library and the library to use when compiling your source. You need to provide the -I and the -L directive to g++ to specify the include path for the library and the library itself respsectively.

Upvotes: 0

Related Questions