I'm trying to use the libstudxml library:
libstudxml: modern C++ XML API
Github Repository: 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? 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.
And to run the executable, you need:
LD_LIBRARY_PATH=/usr/local/lib ./a.out
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.