Hi Jason,
I use this command line to compile : gcc `xml2-config --cflags --libs` -o librairie_xml librairie_xml.c
With or without -I libxml2-2.7.8/include, the result is still the same :
gcc `xml2-config --cflags --libs` -o librairie_xml /librairie_xml.c
In file included from ../librairie_xml.c:24:
../librairie_xml.h:49: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'xmlNewDoc'
../librairie_xml.h:51: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'xmlNodePtr'
../librairie_xml.h:54: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'xmlNodePtr'
../librairie_xml.h:57: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'xmlNodePtr'
../librairie_xml.h:62: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'xmlNodePtr'
../librairie_xml.h:65: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'xmlNodePtr'
../librairie_xml.h:69: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'int'
../librairie_xml.h:74: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'void'
../librairie_xml.c:47: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'xmlNewDoc'
../librairie_xml.c:70: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'xmlNodePtr'
../librairie_xml.c:94: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'xmlNodePtr'
../librairie_xml.c:119: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'xmlNodePtr'
../librairie_xml.c:145: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'xmlNodePtr'
../librairie_xml.c:170: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'xmlNodePtr'
../librairie_xml.c:197: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'int'
../librairie_xml.c:222: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'void'
In file included from ../librairie_xml.c:24:
../librairie_xml.h:49: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'xmlNewDoc'
../librairie_xml.h:51: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'xmlNodePtr'
../librairie_xml.h:54: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'xmlNodePtr'
../librairie_xml.h:57: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'xmlNodePtr'
../librairie_xml.h:62: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'xmlNodePtr'
../librairie_xml.h:65: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'xmlNodePtr'
../librairie_xml.h:69: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'int'
../librairie_xml.h:74: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'void'
../librairie_xml.c:47: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'xmlNewDoc'
../librairie_xml.c:70: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'xmlNodePtr'
../librairie_xml.c:94: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'xmlNodePtr'
../librairie_xml.c:119: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'xmlNodePtr'
../librairie_xml.c:145: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'xmlNodePtr'
../librairie_xml.c:170: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'xmlNodePtr'
../librairie_xml.c:197: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'int'
../librairie_xml.c:222: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'void'
I tried to put all the include of the .h file into the .c file, it just removes the errors coming from the .h file.
I also tried #include <libxml/tree.h> as well as #include "libxml/tree.h", it made no difference.
The most disturbing is all of this, it's that I can still compile the file in which I did my first tests with libxml, (which is in the same folder than librairie_xml.c), named test_short.c, using the same command line : gcc `xml2-config --cflags --libs` -o test test2.c
And it works ! I can compile and execute it without any problem. I tried to compare them, but the only major difference is that test_short.c has a main. But it has nothing to do with my errors.
I joined 3 files to this mail, test_short.c, librairie_xml.c and librairie_xml.h, if anyone can find out what's wrong.
Thanks a lot
A : [email protected]
De : Jason Viers <[email protected]>
Envoyé par : [email protected]
Date : 11/07/2012 17:14
Objet : Re: [xml] Trouble compiling a library
On 7/11/2012 11:03, [email protected] wrote:
> [emmji xml]$ gcc -c lib.c
> In file included from lib.h:25,
> from lib.c:24:
> libxml2-2.7.8/include/libxml/parser.h:15:31: error: libxml/xmlversion.h: No such file or directory
It expects libxml's "include" directory to be in the include path. If
you compile with
-I libxml2-2.7.8/include
and use the same path in your own code, like
#include "libxml/parser.h"
it should work.
If libxml's fully installed, you can also use xml2-config to make the
right flags automatically:
xml2-config --cflags
Jason
_______________________________________________
xml mailing list, project page http://xmlsoft.org/
[email protected]
https://mail.gnome.org/mailman/listinfo/xml
This message is intended exclusively for the designated addressee. It may contain confidential material. If you are not the correct addressee, please notify the sender immediately and destroy the message. The content of this message will engage the responsibility of Steria only if it has been sent by an authorized person acting in the strict scope of his functions and for purposes that are related to his competence. Although reasonable efforts have been made to keep this transmission free from viruses, the sender will not be liable for damages caused by a transmitted virus.
librairie_xml.c
Description: Binary data
librairie_xml.h
Description: Binary data
test_short.c
Description: Binary data
_______________________________________________ xml mailing list, project page http://xmlsoft.org/ [email protected] https://mail.gnome.org/mailman/listinfo/xml
