C++ expat对'XML_SetElementHandler';

C++ expat对'XML_SetElementHandler';,c++,compiler-errors,linker,linker-errors,expat-parser,C++,Compiler Errors,Linker,Linker Errors,Expat Parser,当我使用expat xml库构建程序时,我遇到了这些链接器错误 3288 /tmp/ccFZziQa.o: In function `xml::node::load_xml(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >)': 3289 node.cpp:(.text+0xdec): undefined reference to `XML_SetEl

当我使用expat xml库构建程序时,我遇到了这些链接器错误

3288 /tmp/ccFZziQa.o: In function `xml::node::load_xml(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >)':
3289 node.cpp:(.text+0xdec): undefined reference to `XML_SetElementHandler'
3290 node.cpp:(.text+0xe08): undefined reference to `XML_SetCharacterDataHandler'
3291 node.cpp:(.text+0xe2c): undefined reference to `XML_SetUserData'
3292 node.cpp:(.text+0xe72): undefined reference to `XML_Parse'
3293 node.cpp:(.text+0xeaa): undefined reference to `XML_GetErrorCode'
3294 node.cpp:(.text+0xeb1): undefined reference to `XML_ErrorString'
3295 node.cpp:(.text+0xecb): undefined reference to `XML_GetCurrentLineNumber'
文件系统上有库:

$LIBEPAT.so

/lib/x86_64-linux-gnu/libexpat.so.1
/lib/x86_64-linux-gnu/libexpat.so.1.6.0
/usr/lib/x86_64-linux-gnu/libexpat.so
运行strace检查是否存在任何明显问题:

g++ -v  -L /usr/lib/x86_64-linux-gnu -lexpat node.cpp
2170 [pid  3361] open("/usr/include/expat.h", O_RDONLY|O_NOCTTY) = 4

3172 [pid  3364] stat("/usr/lib/x86_64-linux-gnu/libexpat.so", {st_mode=S_IFREG|0644, st_size=166032, ...}) = 0
3173 [pid  3364] open("/usr/lib/x86_64-linux-gnu/libexpat.so", O_RDONLY) = 7
3174 [pid  3364] open("/usr/lib/x86_64-linux-gnu/libexpat.so", O_RDONLY) = 8
3175 [pid  3364] stat("/tmp/ccFZziQa.o", {st_mode=S_IFREG|0600, st_size=89008, ...}) = 0
3176 [pid  3364] open("/tmp/ccFZziQa.o", O_RDONLY) = 8
3177 [pid  3364] open("/tmp/ccFZziQa.o", O_RDONLY) = 9




3172 [pid  3364] stat("/usr/lib/x86_64-linux-gnu/libexpat.so", {st_mode=S_IFREG|0644, st_size=166032, ...}) = 0
3173 [pid  3364] open("/usr/lib/x86_64-linux-gnu/libexpat.so", O_RDONLY) = 7
3174 [pid  3364] open("/usr/lib/x86_64-linux-gnu/libexpat.so", O_RDONLY) = 8
3175 [pid  3364] stat("/tmp/ccFZziQa.o", {st_mode=S_IFREG|0600, st_size=89008, ...}) = 0
3176 [pid  3364] open("/tmp/ccFZziQa.o", O_RDONLY) = 8
3177 [pid  3364] open("/tmp/ccFZziQa.o", O_RDONLY) = 9
当所有内容都正确加载时,链接器为什么会抛出这些错误,你知道吗

我可以在符号表中查找函数:-

$ nm -DC /usr/lib/x86_64-linux-gnu/libexpat.so |grep XML_SetElementHandler 
000000000000d4a0 T XML_SetElementHandler
看。基本上,在g++命令行中,将源文件移到expat库之前。。。差不多

g++ -v node.cpp -L /usr/lib/x86_64-linux-gnu -lexpat