htmlcxx0.84编译错误

htmlcxx0.84 compilation error

本文关键字:错误 编译 htmlcxx0      更新时间:2023-10-16

我尝试使用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的文件的路径,其中XXXname_of_library

在您的情况下,您应该在/home/lubhavan/htmlcxx-0.84/中查找一个以lib开头、以.a结尾的文件。/path/to/library是该文件所在的路径。name_of_library是不带前导lib和尾随.a的文件名。