Re: [xml] The order of arguments when compiling

2012-02-20 Thread spam . spam . spam . spam
Yes it looks more like you said, and I forgot the second step, my apologizes. I 
got this second step:
$ gcc -Wall -Wextra `xml2-config --cflags` -g -O2 -o xmlparsefile 
xmlparsefile-main.o
As you can see, it doesn't show the `xml2-config --libs` argument (given into 
my Makefile.am with the _LIBS option).

Also, be careful because the `xml2-config --ldflags` is a bad usage because the 
'--ldflags' option doesn't exists:
---
`$ xml2-config --ldflags
Usage: xml2-config [OPTION]

Known values for OPTION are:

  --prefix=DIR  change libxml prefix [default 
/home/spierre/software/libxml2-2.7.8]
  --exec-prefix=DIR change libxml exec prefix [default 
/home/spierre/software/libxml2-2.7.8]
  --libsprint library linking information
  --cflags  print pre-processor and compiler flags
  --modules module support enabled
  --helpdisplay this help and exit
  --version output version information
---

With Automake, the value of the _LDFLAGS option is not put at the end of the 
compilation line. And it's the real problem.
I got something like this :
$ gcc -Wall -Wextra  `xml2-config --cflags` `xml2-config --libs` -o 
xmlparsefile xmlparsefile-main.o
But I would like something like this :
$ gcc -Wall -Wextra  `xml2-config --cflags` -o xmlparsefile xmlparsefile-main.o 
`xml2-config --libs`

Do you know how to do this?

- Mail original -
De: Noam Postavsky npost...@users.sourceforge.net
À: xml@gnome.org
Envoyé: Vendredi 17 Février 2012 17:39:25
Objet: Re: [xml] The order of arguments when compiling

On Fri, Feb 17, 2012 at 7:12 AM,  spam.spam.spam.s...@free.fr wrote:
 The compile does now :
 $ gcc -DPACKAGE_NAME=\xmlparsefile\ -DPACKAGE_TARNAME=\xmlparsefile\ 
 -DPACKAGE_VERSION=\0.1\ -DPACKAGE_STRING=\xmlparsefile\ 0.1\ 
 -DPACKAGE_BUGREPORT=\samson.pie...@etud.univ-montp2.fr\ -DPACKAGE_URL=\\ 
 -DPACKAGE=\xmlparsefile\ -DVERSION=\0.1\ -I.    -Wall -Wextra 
 `xml2-config --cflags` -g -O2 -MT xmlparsefile-main.o -MD -MP -MF 
 .deps/xmlparsefile-main.Tpo -c -o xmlparsefile-main.o `test -f 'main.c' || 
 echo './'`main.c
 mv -f .deps/xmlparsefile-main.Tpo .deps/xmlparsefile-main.Po

 So, it does something like this :
 $ gcc -Wall -Wextra `xml2-config --cflags` main.c

That looks more like this:
$ gcc -Wall -Wextra  `xml2-config --cflags` -c -o main.o main.c

There should be a second linking step which should like this:
$ gcc -Wall -Wextra  `xml2-config --cflags` main.o `xml2-config --ldflags`
___
xml mailing list, project page  http://xmlsoft.org/
xml@gnome.org
http://mail.gnome.org/mailman/listinfo/xml
___
xml mailing list, project page  http://xmlsoft.org/
xml@gnome.org
http://mail.gnome.org/mailman/listinfo/xml


Re: [xml] The order of arguments when compiling

2012-02-20 Thread spam . spam . spam . spam
Hum... I prefer a solution which works if we type :
$ ./configure
$ make
$ make install

If I request my users to do :
$ ./configure
$ make LIBS=`xml2-config --libs`
$ make install
I think they will not be happy.

The best thing is to edit my Makefile.am correctly.

Do you know what is incorrect in my Makefile.am?

- Mail original -
De: Earnie Boyd ear...@users.sourceforge.net
À: spam spam spam spam spam.spam.spam.s...@free.fr
Cc: xml@gnome.org
Envoyé: Vendredi 17 Février 2012 16:11:43
Objet: Re: [xml] The order of arguments when compiling

On Fri, Feb 17, 2012 at 7:12 AM,  wrote:

 are you aware of the LIBS option?


Something like

make LIBS=`xml2-config --libs`

-- 
Earnie
-- https://sites.google.com/site/earnieboyd
___
xml mailing list, project page  http://xmlsoft.org/
xml@gnome.org
http://mail.gnome.org/mailman/listinfo/xml


Re: [xml] The order of arguments when compiling

2012-02-20 Thread spam . spam . spam . spam
Thank you for this option.
But if I use it like this :
bin_PROGRAMS = xmlparsefile
xmlparsefile_SOURCES = main.c
xmlparsefile_LDADD = `xml2-config --libs`
xmlparsefile_CFLAGS = -Wall -Wextra `xml2-config --cflags`

I got :
$ autoreconf
src/Makefile.am:3: linker flags such as `--libs`' belong in 
`xmlparsefile_LDFLAGS
make: *** [Makefile.in] Error 1

Are you sure about _LDADD now?

- Mail original -
De: Christian Engwer christian.eng...@uni-muenster.de
À: spam spam spam spam spam.spam.spam.s...@free.fr
Cc: xml@gnome.org
Envoyé: Vendredi 17 Février 2012 15:48:00
Objet: Re: [xml] The order of arguments when compiling

On Fri, Feb 17, 2012 at 01:12:04PM +0100, spam.spam.spam.s...@free.fr wrote:
 Indeed, I don't know this option.
 But, if I use it in my Makefile.am:
 bin_PROGRAMS = xmlparsefile
 xmlparsefile_SOURCES = main.c
 xmlparsefile_LIBS = `xml2-config --libs`
 xmlparsefile_CFLAGS = -Wall -Wextra `xml2-config --cflags`
 
 The compile does now :
 $ gcc -DPACKAGE_NAME=\xmlparsefile\ -DPACKAGE_TARNAME=\xmlparsefile\ 
 -DPACKAGE_VERSION=\0.1\ -DPACKAGE_STRING=\xmlparsefile\ 0.1\ 
 -DPACKAGE_BUGREPORT=\samson.pie...@etud.univ-montp2.fr\ -DPACKAGE_URL=\\ 
 -DPACKAGE=\xmlparsefile\ -DVERSION=\0.1\ -I.-Wall -Wextra 
 `xml2-config --cflags` -g -O2 -MT xmlparsefile-main.o -MD -MP -MF 
 .deps/xmlparsefile-main.Tpo -c -o xmlparsefile-main.o `test -f 'main.c' || 
 echo './'`main.c
 mv -f .deps/xmlparsefile-main.Tpo .deps/xmlparsefile-main.Po
 
 So, it does something like this :
 $ gcc -Wall -Wextra `xml2-config --cflags` main.c
 
 And I got the same error.
 
 The `xml2-config --libs` has completely disappeared.
 
 Are you sure about _LIBS option?

Oh sorry... it is _LDADD.

Christian

 - Mail original -
 De: Christian Engwer christian.eng...@uni-muenster.de
 À: spam spam spam spam spam.spam.spam.s...@free.fr
 Cc: xml@gnome.org
 Envoyé: Vendredi 17 Février 2012 12:42:41
 Objet: Re: [xml] The order of arguments when compiling
 
 Hi,
 
  xmlparsefile_SOURCES = main.c
  xmlparsefile_LDFLAGS = `xml2-config --libs`
 
 are you aware of the LIBS option?
 
 xmlparsefile_LIBS = ...
 
 This should allow for the approriate ordering.
 
 Christian
 
  xmlparsefile_CFLAGS = -Wall -Wextra `xml2-config --cflags`
  
  I think it's strange that GNU Automake do this choice if this is not 
  compatible with most Unix linkers...
  
  I will ask the GNU Automake mailing list to know if there is a way to set a 
  different argument order than the default.
  
  Any other suggestion is welcome.
  
  - Mail original -
  De: Csaba Raduly rcs...@gmail.com
  À: spam spam spam spam spam.spam.spam.s...@free.fr
  Cc: xml@gnome.org
  Envoyé: Vendredi 17 Février 2012 09:55:52
  Objet: Re: [xml] The order of arguments when compiling
  
  Hi spam,
  
  On Thu, Feb 16, 2012 at 4:01 PM,   wrote:
   Hello,
  
   On a first computer, when I compile a C program using the libxml2 library 
   I do :
   $ gcc `xml2-config --cflags` `xml2-config --libs` main.c
   or
   $ gcc main.c `xml2-config --cflags` `xml2-config --libs`
   And it works (but the first method is better because it respects the 
   order of arguments in the gcc manual).
  
   On a second computer, if I compile like this, there is an error :
   $ gcc `xml2-config --cflags` `xml2-config --libs` main.c
   /tmp/cc7uNwed.o: In function `parseDoc':
   main.c:(.text+0xd): undefined reference to `xmlParseFile'
   main.c:(.text+0x51): undefined reference to `xmlCleanupParser'
   main.c:(.text+0x63): undefined reference to `xmlFreeDoc'
   main.c:(.text+0x68): undefined reference to `xmlCleanupParser'
   collect2: ld returned 1 exit status
   But if I compile like this, there is no error :
   $ gcc main.c `xml2-config --cflags` `xml2-config --libs`
  
   I thought this was a gcc problem but someone on the gcc mailing-list tell 
   me that probably I have compiled libxml2 on the second computer 
   statically. And I should compile it dynamically. It's true that on 
   the second computer, I have compiled myself the library (configure, make, 
   make install). On the first computer, this is my distro package.
  
   How should I compile libxml2 on the 2nd computer to have the same 
   behavior on the two computers?
  
  You shouldn't; just use the last compilation command (with
  `xml2-config --libs` at the end).
  Most Unix linkers are one-pass; because of this, an object which needs
  a symbol must appear before the object (or library) which supplies
  that symbol.
  
  See for example http://webpages.charter.net/ppluzhnikov/linker.html
  
  GNU make's built-in rule for linking boils down to:
  
  %: %.c
  #  commands to execute (built-in):
   $(CC) $(CFLAGS) $(CPPFLAGS) $(LDFLAGS) $(TARGET_ARCH)  $^
  $(LOADLIBES) $(LDLIBS) -o $@
  
  %: %.o
  $(CC) $(LDFLAGS) $(TARGET_ARCH)  $^  $(LOADLIBES)
  $(LDLIBS) -o $@
  
  As you can see, the list of source or object files ($^) is always
  _before_ the list of libraries (in $(LDLIBS) or $(LOADLIBES

Re: [xml] The order of arguments when compiling

2012-02-20 Thread spam . spam . spam . spam
Easy to get the -L options and -l options separatly with a good old 'cut' :
$ xml2-config --libs | cut -d   -f 1
-L/home/spierre/software/libxml2-2.7.8/lib
$ xml2-config --libs | cut -d   -f 2-
-lxml2 -lz -lm

My new Makefile.am:
bin_PROGRAMS = xmlparsefile
xmlparsefile_SOURCES = main.c
xmlparsefile_LDFLAGS = `xml2-config --libs | cut -d   -f 1`
xmlparsefile_LDADD = `xml2-config --libs | cut -d   -f 2-`
xmlparsefile_CFLAGS = -Wall -Wextra `xml2-config --cflags

But error :
$ autoreconf
src/Makefile.am:4: linker flags such as `--libs' belong in `xmlparsefile_LDFLAGS
autoreconf: automake failed with exit status: 1

Do you see how to avoid this error?

- Mail original -
De: Csaba Raduly rcs...@gmail.com
À: spam spam spam spam spam.spam.spam.s...@free.fr
Cc: xml@gnome.org
Envoyé: Lundi 20 Février 2012 10:05:45
Objet: Re: [xml] The order of arguments when compiling

On Mon, Feb 20, 2012 at 9:06 AM,  spam.spam.spam.s...@free.fr wrote:
 Hum... I prefer a solution which works if we type :
 $ ./configure
 $ make
 $ make install

 If I request my users to do :
 $ ./configure
 $ make LIBS=`xml2-config --libs`
 $ make install
 I think they will not be happy.

 The best thing is to edit my Makefile.am correctly.

 Do you know what is incorrect in my Makefile.am?

I think that  `xml2-config --libs` , which outputs -L options (that go
into LDFLAGS) and -l options (that go into LDADD) together, does not
play well with automake that expects them separately.
If xml2-config had separate --ldflags and --libs options, it would
have been easier for you. Unfortunately, it doesn't.

Csaba
-- 
GCS a+ e++ d- C++ ULS$ L+$ !E- W++ P+++$ w++$ tv+ b++ DI D++ 5++
The Tao of math: The numbers you can count are not the real numbers.
Life is complex, with real and imaginary parts.
Ok, it boots. Which means it must be bug-free and perfect.  -- Linus Torvalds
People disagree with me. I just ignore them. -- Linus Torvalds
___
xml mailing list, project page  http://xmlsoft.org/
xml@gnome.org
http://mail.gnome.org/mailman/listinfo/xml


Re: [xml] The order of arguments when compiling

2012-02-20 Thread Noam Postavsky
spam.spam.spam.s...@free.fr writes:

 Thank you for this option.
 But if I use it like this :
 bin_PROGRAMS = xmlparsefile
 xmlparsefile_SOURCES = main.c
 xmlparsefile_LDADD = `xml2-config --libs`
 xmlparsefile_CFLAGS = -Wall -Wextra `xml2-config --cflags`

 I got :
 $ autoreconf
 src/Makefile.am:3: linker flags such as `--libs`' belong in 
 `xmlparsefile_LDFLAGS
 make: *** [Makefile.in] Error 1

Interesting, but I think things will be cleaner if you get the flags in
configure.ac:

LIBXML_LIBS=`xml2-config --libs`
LIBXML_CFLAGS=`xml2-config --cflags`
AC_SUBST([LIBXML_LIBS])
AC_SUBST([LIBXML_CFLAGS])

or you could use the pkg-config macro which lets you check the version
too:

PKG_CHECK_MODULES([LIBXML], [libxml-2.0 = 2.7.8])

Then Makefile.am:

bin_PROGRAMS = xmlparsefile
xmlparsefile_SOURCES = main.c
xmlparsefile_LDADD = $(LIBXML_LIBS)
xmlparsefile_CFLAGS = -Wall -Wextra $(LIBXML_CFLAGS)

___
xml mailing list, project page  http://xmlsoft.org/
xml@gnome.org
http://mail.gnome.org/mailman/listinfo/xml


Re: [xml] The order of arguments when compiling

2012-02-17 Thread Csaba Raduly
Hi spam,

On Thu, Feb 16, 2012 at 4:01 PM,   wrote:
 Hello,

 On a first computer, when I compile a C program using the libxml2 library I 
 do :
 $ gcc `xml2-config --cflags` `xml2-config --libs` main.c
 or
 $ gcc main.c `xml2-config --cflags` `xml2-config --libs`
 And it works (but the first method is better because it respects the order of 
 arguments in the gcc manual).

 On a second computer, if I compile like this, there is an error :
 $ gcc `xml2-config --cflags` `xml2-config --libs` main.c
 /tmp/cc7uNwed.o: In function `parseDoc':
 main.c:(.text+0xd): undefined reference to `xmlParseFile'
 main.c:(.text+0x51): undefined reference to `xmlCleanupParser'
 main.c:(.text+0x63): undefined reference to `xmlFreeDoc'
 main.c:(.text+0x68): undefined reference to `xmlCleanupParser'
 collect2: ld returned 1 exit status
 But if I compile like this, there is no error :
 $ gcc main.c `xml2-config --cflags` `xml2-config --libs`

 I thought this was a gcc problem but someone on the gcc mailing-list tell me 
 that probably I have compiled libxml2 on the second computer statically. 
 And I should compile it dynamically. It's true that on the second computer, 
 I have compiled myself the library (configure, make, make install). On the 
 first computer, this is my distro package.

 How should I compile libxml2 on the 2nd computer to have the same behavior on 
 the two computers?

You shouldn't; just use the last compilation command (with
`xml2-config --libs` at the end).
Most Unix linkers are one-pass; because of this, an object which needs
a symbol must appear before the object (or library) which supplies
that symbol.

See for example http://webpages.charter.net/ppluzhnikov/linker.html

GNU make's built-in rule for linking boils down to:

%: %.c
#  commands to execute (built-in):
 $(CC) $(CFLAGS) $(CPPFLAGS) $(LDFLAGS) $(TARGET_ARCH)  $^
$(LOADLIBES) $(LDLIBS) -o $@

%: %.o
$(CC) $(LDFLAGS) $(TARGET_ARCH)  $^  $(LOADLIBES)
$(LDLIBS) -o $@

As you can see, the list of source or object files ($^) is always
_before_ the list of libraries (in $(LDLIBS) or $(LOADLIBES) ).

Hope this helps,
Csaba
-- 
GCS a+ e++ d- C++ ULS$ L+$ !E- W++ P+++$ w++$ tv+ b++ DI D++ 5++
The Tao of math: The numbers you can count are not the real numbers.
Life is complex, with real and imaginary parts.
Ok, it boots. Which means it must be bug-free and perfect.  -- Linus Torvalds
People disagree with me. I just ignore them. -- Linus Torvalds
___
xml mailing list, project page  http://xmlsoft.org/
xml@gnome.org
http://mail.gnome.org/mailman/listinfo/xml


Re: [xml] The order of arguments when compiling

2012-02-17 Thread Earnie Boyd
On Fri, Feb 17, 2012 at 7:12 AM,  wrote:

 are you aware of the LIBS option?


Something like

make LIBS=`xml2-config --libs`

-- 
Earnie
-- https://sites.google.com/site/earnieboyd
___
xml mailing list, project page  http://xmlsoft.org/
xml@gnome.org
http://mail.gnome.org/mailman/listinfo/xml


Re: [xml] The order of arguments when compiling

2012-02-17 Thread Noam Postavsky
On Fri, Feb 17, 2012 at 7:12 AM,  spam.spam.spam.s...@free.fr wrote:
 The compile does now :
 $ gcc -DPACKAGE_NAME=\xmlparsefile\ -DPACKAGE_TARNAME=\xmlparsefile\ 
 -DPACKAGE_VERSION=\0.1\ -DPACKAGE_STRING=\xmlparsefile\ 0.1\ 
 -DPACKAGE_BUGREPORT=\samson.pie...@etud.univ-montp2.fr\ -DPACKAGE_URL=\\ 
 -DPACKAGE=\xmlparsefile\ -DVERSION=\0.1\ -I.    -Wall -Wextra 
 `xml2-config --cflags` -g -O2 -MT xmlparsefile-main.o -MD -MP -MF 
 .deps/xmlparsefile-main.Tpo -c -o xmlparsefile-main.o `test -f 'main.c' || 
 echo './'`main.c
 mv -f .deps/xmlparsefile-main.Tpo .deps/xmlparsefile-main.Po

 So, it does something like this :
 $ gcc -Wall -Wextra `xml2-config --cflags` main.c

That looks more like this:
$ gcc -Wall -Wextra  `xml2-config --cflags` -c -o main.o main.c

There should be a second linking step which should like this:
$ gcc -Wall -Wextra  `xml2-config --cflags` main.o `xml2-config --ldflags`
___
xml mailing list, project page  http://xmlsoft.org/
xml@gnome.org
http://mail.gnome.org/mailman/listinfo/xml


Re: [xml] The order of arguments when compiling

2012-02-16 Thread spam . spam . spam . spam
I have just compiled libxml2 the same way on the two computers :
./configure --prefix=...
make
make install

On the first computer, I got no problem when compile.
On the second computer, I got the compile problem.

So, I think the problem is about gcc on the second computer (but they don't 
believe me on the gcc mailing list).

What should I do to compile fine my program with gcc on both computers?

First computer:
$ gcc --version
gcc (Debian 4.4.5-8) 4.4.
$ xml2-config --cflags
-I/home/.../software/libxml2-2.7.8/include/libxml2
$ xml2-config --libs
-L/home/.../software/libxml2-2.7.8/lib -lxml2 -lz -lm

Second computer:
$ gcc --version
gcc (Ubuntu/Linaro 4.6.1-9ubuntu3) 4.6.1.
$ xml2-config --cflags
-I/home/.../software/libxml2-2.7.8/include/libxml2
$ xml2-config --libs
-L/home/.../software/libxml2-2.7.8/lib -lxml2 -lm

Oh! strange thing : -lz is not present... Is it related to my problem?

- Mail original -
De: spam spam spam spam spam.spam.spam.s...@free.fr
À: xml@gnome.org
Envoyé: Jeudi 16 Février 2012 16:01:27
Objet: [xml] The order of arguments when compiling

Hello,

On a first computer, when I compile a C program using the libxml2 library I do :
$ gcc `xml2-config --cflags` `xml2-config --libs` main.c
or
$ gcc main.c `xml2-config --cflags` `xml2-config --libs`
And it works (but the first method is better because it respects the order of 
arguments in the gcc manual).

On a second computer, if I compile like this, there is an error :
$ gcc `xml2-config --cflags` `xml2-config --libs` main.c
/tmp/cc7uNwed.o: In function `parseDoc':
main.c:(.text+0xd): undefined reference to `xmlParseFile'
main.c:(.text+0x51): undefined reference to `xmlCleanupParser'
main.c:(.text+0x63): undefined reference to `xmlFreeDoc'
main.c:(.text+0x68): undefined reference to `xmlCleanupParser'
collect2: ld returned 1 exit status
But if I compile like this, there is no error :
$ gcc main.c `xml2-config --cflags` `xml2-config --libs`

I thought this was a gcc problem but someone on the gcc mailing-list tell me 
that probably I have compiled libxml2 on the second computer statically. And 
I should compile it dynamically. It's true that on the second computer, I 
have compiled myself the library (configure, make, make install). On the first 
computer, this is my distro package.

How should I compile libxml2 on the 2nd computer to have the same behavior on 
the two computers?

Thank you.
___
xml mailing list, project page  http://xmlsoft.org/
xml@gnome.org
http://mail.gnome.org/mailman/listinfo/xml
___
xml mailing list, project page  http://xmlsoft.org/
xml@gnome.org
http://mail.gnome.org/mailman/listinfo/xml