Re: [xml] Trouble compiling a library



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'
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
 

Michael


-----xml-bounces gnome org a Ãcrit : -----

A : xml gnome org
De : Jason Viers <lists beanalby net>
Envoyà par : xml-bounces gnome org
Date : 11/07/2012 17:14
Objet : Re: [xml] Trouble compiling a library

On 7/11/2012 11:03, michael jerusalmi steria com 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/
xml gnome org
https://mail.gnome.org/mailman/listinfo/xml

Ce message est à l'attention exclusive des destinataires dÃsignÃs. Il peut contenir des informations confidentielles. Si vous n'Ãtes pas destinataire du message, merci d'en avertir immÃdiatement l'expÃditeur et de dÃtruire ce message. Le contenu de ce message ne pourrait engager la responsabilità de Steria que s'il a Ãtà Ãmis par une personne dÃment habilitÃe agissant dans le strict cadre de ses fonctions et à des fins non ÃtrangÃres à ses attributions. Bien que les meilleurs efforts soient faits pour maintenir cette transmission exempte de tout virus, l'expÃditeur ne donne aucune garantie à cet Ãgard et sa responsabilità ne saurait Ãtre engagÃe pour tout dommage rÃsultant d'un virus transmis.
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.

Attachment: librairie_xml.c
Description: Binary data

Attachment: librairie_xml.h
Description: Binary data

Attachment: test_short.c
Description: Binary data



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]