htmlcxx0.84编译错误
htmlcxx0.84 compilation error
我尝试使用htmlcxx
来解析网页。问题是,这个例子不可编辑。
当我运行g++ webscrsp.cpp
:时,我得到了这个
/tmp/ccHiUM6o.o:在函数"main"中:webcrsp.cpp:(.text+0x86):对"htmlcxx::HTML::ParserMax::parse(std::basic_string,std::allocater>const&)"的未定义引用webcrsp.cpp:(.text+0xb8):对"htmlcxx::HTML::operator>&,tree>>const&)"的未定义引用/tmp/ccHiUM6o.o:在函数"htmlcxx::HTML::ParserDom::Parser Dom()"中:webcrsp.cpp:(.text._ZN7htmlcxx4HTML9ParserDomC1Ev[htmlcxx::HTML::ParserDom::Parser Dom()]+0x22):对"htmlcxx:HTML::ParerDom的vtable"的未定义引用/tmp/ccHiUM6o.o:在函数"htmlcxx::HTML::ParserDom::~ParserDom()"中:webcrsp.cpp:(.text._ZN7htmlcxx4HTML9ParserDomD1Ev[htmlcxx::HTML::ParserDom::~ParserDom()]+0x16):未定义对"htmlcxx:HTML::ParerDom的vtable"的引用collect2:ld返回1退出状态
我的代码是
#include <string>
#include <iostream>
#include <sstream>
#include </home/lubhavan/htmlcxx-0.84/html/ParserDom.h>
using namespace std;
using namespace htmlcxx;
int main()
{
string html ="<html > <head> <title > hi iam titile </title> </head> <body> <p> what can i do </p> </body> </html>";
HTML::ParserDom parser;
tree<HTML::Node> dom = parser.parseTree(html) ;
cout << dom <<endl;
cout << endl;
return 0;
}
请帮帮我,因为我很快就要做了。我无法理解错误。。。
提前谢谢。。
如果您的整个命令行都是
g++ webscrsp.cpp
然后你会得到链接器错误,因为你没有链接到包含实际代码的库。
你必须这样做:
g++ webscrsp.cpp -L/path/to/library -Wl,-rpath=/path/to/library -lname_of_library
在上面的命令行示例中,/path/to/library
是名为libXXX.a
的文件的路径,其中XXX
是name_of_library
。
在您的情况下,您应该在/home/lubhavan/htmlcxx-0.84/
中查找一个以lib
开头、以.a
结尾的文件。/path/to/library
是该文件所在的路径。name_of_library
是不带前导lib
和尾随.a
的文件名。
相关文章:
- 用MacOS Mojave编译C++:致命错误:mpi.h:没有这样的文件或目录
- std::is_base_of表示ctor编译错误
- 我的项目不会像"undefined reference to `grpc::g_core_codegen_interface'"那样使用未定义的引用错误进行编译
- 在没有定义返回类型的函数中返回布尔值,并将结果保存在无错误的char编译中-为什么
- Qt5:使用QCommandLineParser类时出现奇怪的编译错误
- Qt Cmake 错误编译"GuiSupportQt not found"
- Opengl 精度转换错误编译错误 E0415
- 库将ARM架构错误编译为架构X64
- RT 音频 Mac 错误 g++ 编译错误
- 错误编译Boost.log
- 错误编译QT创建者 / QT窗口小部件示例
- 错误编译MIPS32
- Visual Studio 2013 中的错误(编译和运行代码)
- 链接错误编译qt项目在visual 2010
- 无法用模板错误编译nsgmls
- 奇怪的错误.编译失败
- 如果有人调用c++中的方法,则强制错误(编译时)
- 来自autoconf测试的错误编译命令
- 时间限制超出错误C++编译
- SFML 2.3 和 CodeBlocks 错误编译