[英]C++ code using the “libstudxml” library won't compile, or link
我正在尝试使用libstudxml库:
Github存储库:windoze / libstudxml
但是我的代码无法编译,我可能未与该库链接...有人知道我是否需要与libstudxml库链接? 还是我做错了什么?
这就是我的编译方式:
g++ -std=c++11 main.cpp
我想念什么吗?
g++ -std=c++11 main.cpp -l??????
这是我要编译的代码:
#include <iostream>
#include <fstream>
#include <xml/parser>
#include <xml/serializer>
int main()
{
std::ifstream ifs( "file.xml" );
xml::parser p( ifs, "file.xml" );
}
这是我得到的错误:
/tmp/ccLqLaZq.o: In function 'main':
main.cpp:(.text+0xa9):
undefined reference to 'xml::parser::~parser()'
/tmp/ccLqLaZq.o: In function 'xml::parser::parser(std::istream&,
std::string const&, unsigned short)':
main.cpp:(.text._ZN3xml6parserC2ERSiRKSst[_ZN3xml6parserC5ERSiRKSst]+0xd5):
undefined reference to 'xml::parser::init()'
collect2: error: ld returned 1 exit status
编译和链接代码所需的命令是:
g++ -std=c++11 main.cpp -lstudxml
感谢Oleg Andriyanov。
要运行可执行文件,您需要:
LD_LIBRARY_PATH=/usr/local/lib ./a.out
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.