为什么在 libc++ 中使用 clang 时出现以下链接器错误:
$ clang++ -stdlib=libc++ po.cxx -lpoppler
/tmp/po-QqlXGY.o: In function `main':
po.cxx:(.text+0x33): undefined reference to `Dict::lookup(char*, Object*, std::__1::set<int, std::__1::less<int>, std::__1::allocator<int> >*)'
clang: error: linker command failed with exit code 1 (use -v to see invocation)
在哪里:
$ nm -D /usr/lib/x86_64-linux-gnu/libpoppler.so | grep lookup | c++filt| grep \ Dict::lookup\(
00000000000c1870 T Dict::lookup(char*, Object*, std::set<int, std::less<int>, std::allocator<int> >*)
代码很简单:
#include <poppler/PDFDoc.h>
int main()
{
Dict *infoDict;
Object obj;
infoDict->lookup((char*)"key", &obj);
return 0;
}