簡體   English   中英

使用“ libstudxml”庫的C ++代碼將無法編譯或鏈接

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

我正在嘗試使用libstudxml庫:

libstudxml:現代C ++ XML API

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.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM