包括libxml中的标头之后:
#include "libxml/HTMLparser.h"
链接器无法从HTMLparser中找到方法,并给出n错误
/usr/bin/ld: /tmp/ccinQCC4.o: in function `main':
test.cpp:(.text+0x5c): undefined reference to `htmlParseFile'
collect2: error: ld returned 1 exit status
我试图编译HTMLparser.h,但是由于缺乏权限,我无法编译。
我不知道现在该怎么办,因为我在代码中找不到任何问题:
#include "iostream"
#include "list"
#include "libxml/HTMLparser.h"
#include "libxml/HTMLtree.h"
int main(){
std::string url = "https://rd.springer.com/article/10.1007/s10951-009-0156-2";
htmlDocPtr tree = htmlParseFile(url.c_str(),nullptr);
return 1;
}
或者可以使用我之前在命令行中使用的附加命令来回避问题:
g++ -L /usr/include/libxml2 -I /usr/include/libxml2 test.cpp
如果有人可以帮助我,那就太好了