chakka.lokesh
(Lokesh Venkata Kumar Chakka)
April 15, 2024, 10:56am
1
I’ve installed xml library using the command pacman -S libxml2
in msys2 terminal
in MINGW64 terminal,
I’ve written a small piece of code to create xml file
#include<tree.h>
int main()
{
xmlNodePtr root_node = xmlNewNode(NULL, (xmlChar const *)"MY_root_Node");
xmlDocPtr doc = xmlNewDoc( (const xmlChar *)"1.0" );
xmlDocSetRootElement( doc, root_node );
xmlNewChild( root_node, NULL, (xmlChar*)"for_learning", "value" );
xmlSaveFormatFileEnc( "mylearning.xml", doc, "UTF-8", 1 );
xmlFreeDoc( doc );
xmlCleanupParser();
}
while trying to compile I’m seeing the following error
DELL@Lokesh-Windows MINGW64 ~
$ gcc two.c -lxml2
two.c:1:9: fatal error: tree.h: No such file or directory
1 | #include<tree.h>
| ^~~~~~~~
compilation terminated.
In entire /usr directory, there is no tree.h file.
can someone please help me how to compile this program.
thanks.
Hi,
libxml2
is the cygwin package.
When working with mingw64, please install the mingw version:
pacman -S mingw-w64-x86_64-libxml2
By the way, it should be:
#include <libxml/tree.h>
nwellnhof
(Nick Wellnhofer)
April 15, 2024, 11:17am
4
This should give you the required compiler and linker flags:
pkg-config --cflags libxml-2.0
pkg-config --libs libxml-2.0
Also see the FAQ .
chakka.lokesh
(Lokesh Venkata Kumar Chakka)
April 15, 2024, 12:02pm
5
thanks.
I’m able to compile the code and execute as well.
in Linux, we used to see the folder libxml in /usr/include
whereas here there is no such folder in /usr/include
the reason I’m asking is I’m using openssl library as well and I’m not able to compile because of this error :
fatal error: openssl/ssl.h: No such file or directory
4 | #include<openssl/ssl.h>
I’ve already installed pacman -S mingw-w64-clang-x86_64-openssl
You must install mingw-w64-x86_64-openssl
instead of mingw-w64-clang-x86_64-openssl
, for consistency.
On Windows with MSYS2, there are several runtimes available:
a cygwin runtime, only used for basic core tools, installed under /usr
a mingw64 one (the one you are using), installed under /mingw64
there are also mingw32, clang, ucrt64 runtimes. They use different runtimes and standard libraries.
When developing for mingw64, headers are expected to be under /mingw64/include/
.
Other runtimes will use other include paths.