简体   繁体   English

使用“ libstudxml”库的C ++代码将无法编译或链接

[英]C++ code using the “libstudxml” library won't compile, or link

I'm trying to use the libstudxml library: 我正在尝试使用libstudxml库:

libstudxml: modern C++ XML API libstudxml:现代C ++ XML API

Github Repository: windoze/libstudxml Github存储库:windoze / libstudxml

But my code won't compile, I'm probably not link with the library... Does anyone know if I need to link with the libstudxml library? 但是我的代码无法编译,我可能未与该库链接...有人知道我是否需要与libstudxml库链接? or what i'm doing wrong? 还是我做错了什么?

This is how I'm compiling: 这就是我的编译方式:

g++ -std=c++11 main.cpp

Am I missing something? 我想念什么吗?

g++ -std=c++11 main.cpp -l??????

This is the code I'm trying to compile: 这是我要编译的代码:

#include <iostream>
#include <fstream>
#include <xml/parser>
#include <xml/serializer>
int main()
{
  std::ifstream ifs( "file.xml" );
  xml::parser p( ifs, "file.xml" );
}

And this is the error I get: 这是我得到的错误:

/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

The command needed to compile and link the code is: 编译和链接代码所需的命令是:

g++ -std=c++11 main.cpp -lstudxml 

Thanks to Oleg Andriyanov. 感谢Oleg Andriyanov。

And to run the executable, you need: 要运行可执行文件,您需要:

LD_LIBRARY_PATH=/usr/local/lib ./a.out

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM