0

I have the following C++ code which I am trying to use to parse web pages into a simpler format:

#include <iostream>
#include "libxml2/libxml/xmlexports.h"
#include "libxml2/libxml/xmlversion.h"
#include "libxml2/libxml/HTMLparser.h"

int main(int argc, char *argv[])
{
    char *filename = argv[1];

    std::cout << htmlParseFile(filename, "utf-8");
    
    return 0;
}

The LSP recognises the htmlParseFile function however when I try to compile I get the following error: undefined reference to 'htmlParseFile' The compile command I am using is g++ ~/cpp\ test/test.cpp -I/usr/include/libxml2 so all the necessary files should be included. What am I doing wrong?

I tried adding the -I/usr/include/libxml2 part of my compile command which changed the compiler error that I got from libxml/xmlexports.h: No such file or directory to the one I currently get.

Edit 1

The suggested post isn't helpful as I have already included the whole libxml2 library in the compile command and added the correct header files. I could be using the wrong include command which, for this specific purpose, will not be obvious to people trying to use this library. I need to know which files to include for this specific purpose.

0 Answers0