我正在尝试使用Poco C ++库在Mac OS X 10.8.2上用C ++编写简单的http请求。我安装了Poco,从this tutorial复制粘贴http_request.cc代码,用'g ++ -o http_get http_get.cc -lPocoNet'运行它,但得到了:
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
这几个小时一直在努力。知道如何解决这个问题吗?提前谢谢!
答案 0 :(得分:3)
Poco::URI
,Poco::StreamCopier
类位于PocoFoundation
库中,因此您还需要链接到该库。
g++ -o http_get http_get.cc -lPocoNet -lPocoFoundation
答案 1 :(得分:0)
您似乎没有为编译源时指定库和库使用的包含路径。 您需要向g ++提供-I和-L指令,以便为库和库本身指定包含路径。