You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@apr.apache.org by Graham Leggett <mi...@sharp.fm> on 2005/01/14 15:33:02 UTC
Looking for HOWTO: Linking to APR
Hi all,
One piece of the docs that seems to be missing is a howto describing the
"right" way to link to APR. apr-config offers me an array of options, but
only indicates help if you're using libtool (I am not, my app is an
application) or want to compile statically (I would like to compile
dynamically). It does not tell you how to link to a dynamic library on the
system in a portable way.
What flags (in other words apr-config --<something>) must be used at the
compile stage? What flags must be used at the link stage?
I have code that links to APR fine on MacOSX, but build the same code on
Solaris v2.8 and it bombs out with the error below. I am pretty sure I am
using the wrong apr-config flags, but without knowing what the right flags
are supposed to be I am pretty stuck:
cc -DHAVE_CONFIG_H -I. -I. -I../../src/include
-I/udd001/app/spread/usr/include/apr-0 -g -c -o diablo-diablo.o `test -f
'diablo.c' || echo './'`diablo.c
cc -g -o diablo -L/udd001/app/spread/usr/lib -lapr-0 -lsendfile -lrt
-lm -lsocket -lnsl -lresolv -lpthread -ldl diablo-diablo.o
ild: (bad file) archive subfile #1 in
/udd001/app/spread/usr/lib/libapr-0.a is a file of unknown type
*** Error code 1
Regards,
Graham
--
Re: Looking for HOWTO: Linking to APR
Posted by Reid Spencer <re...@x10sys.com>.
On Mon, 2005-01-17 at 07:02, Graham Leggett wrote:
> Very weird:
>
> bash-2.03$ ar -tv /udd001/app/spread/usr/lib/libapr-0.a
> rw-r--r-- 501/ 501 12156 Dec 21 13:42 2004 #1
> rw-r--r-- 501/ 501 4860 Dec 21 13:41 2004 apr_cpystrn.o
> rw-r--r-- 501/ 501 5352 Dec 21 13:41 2004 apr_fnmatch.o
> rw-r--r-- 501/ 501 30852 Dec 21 13:41 2004 apr_snprintf.o
> rw-r--r-- 501/ 501 10008 Dec 21 13:41 2004 apr_strings.o
> rw-r--r-- 501/ 501 5204 Dec 21 13:41 2004 apr_strnatcmp.o
> [snip]
>
> Is the file #1 supposed to be there? I assume not, thus the message
> "archive subfile #1 is a file of unknown type". Anyone know what could
> have caused this file?
The ar file format permits only 15 characters per file name in its file
header. To get around this, on BSD type implementations of ar, the
special file name "#1/" followed by a sequence of digits ([0-9]*)
indicates that the long file name occurs immediately after the file
header (but before the file content) and its length is given by the
sequence of digits. Since all short file names are terminated with a
slash, here's what I expect is going on:
1. The archive was created with a BSD style "ar" implementation and the
first member has a long (>15 chars) file name.
2. The archive is being read with an SVR4 style "ar" which doesn't
grok the #1/[0-9]* file name notation. Consequently it is reading
the #1 as a file name and stopping at the /.
Either that or the archive header of the first member is corrupt.
Here's some more details:
SVR4 Format:
http://publibn.boulder.ibm.com/doc_link/en_US/a_doc_lib/files/aixfiles/ar_IA64.htm
BSD Format:
http://developer.apple.com/documentation/Darwin/Reference/ManPages/man5/ar.5.html
Hope that helps.
Reid Spencer.
Re: Looking for HOWTO: Linking to APR
Posted by Graham Leggett <mi...@sharp.fm>.
Joe Orton said:
>> cc -DHAVE_CONFIG_H -I. -I. -I../../src/include
>> -I/udd001/app/spread/usr/include/apr-0 -g -c -o diablo-diablo.o `test -f
>> 'diablo.c' || echo './'`diablo.c
>> cc -g -o diablo -L/udd001/app/spread/usr/lib -lapr-0 -lsendfile -lrt
>> -lm -lsocket -lnsl -lresolv -lpthread -ldl diablo-diablo.o
>> ild: (bad file) archive subfile #1 in
>> /udd001/app/spread/usr/lib/libapr-0.a is a file of unknown type
>
> That's pretty weird. You weren't mixing 64-bit and 32-bit objects or
> anything? "ar -tv" output on libapr-0.a show anything other than .o
> files in the archive?
Very weird:
bash-2.03$ ar -tv /udd001/app/spread/usr/lib/libapr-0.a
rw-r--r-- 501/ 501 12156 Dec 21 13:42 2004 #1
rw-r--r-- 501/ 501 4860 Dec 21 13:41 2004 apr_cpystrn.o
rw-r--r-- 501/ 501 5352 Dec 21 13:41 2004 apr_fnmatch.o
rw-r--r-- 501/ 501 30852 Dec 21 13:41 2004 apr_snprintf.o
rw-r--r-- 501/ 501 10008 Dec 21 13:41 2004 apr_strings.o
rw-r--r-- 501/ 501 5204 Dec 21 13:41 2004 apr_strnatcmp.o
[snip]
Is the file #1 supposed to be there? I assume not, thus the message
"archive subfile #1 is a file of unknown type". Anyone know what could
have caused this file?
Regards,
Graham
--
Re: Looking for HOWTO: Linking to APR
Posted by Joe Orton <jo...@redhat.com>.
On Fri, Jan 14, 2005 at 04:33:02PM +0200, Graham Leggett wrote:
> Hi all,
>
> One piece of the docs that seems to be missing is a howto describing the
> "right" way to link to APR. apr-config offers me an array of options, but
> only indicates help if you're using libtool (I am not, my app is an
> application) or want to compile statically (I would like to compile
> dynamically). It does not tell you how to link to a dynamic library on the
> system in a portable way.
>
> What flags (in other words apr-config --<something>) must be used at the
> compile stage? What flags must be used at the link stage?
I'd say: --cppflags, --includes and --cflags at compile stage,
--ldflags, --cflags, --libs and --link-ld at link stage, and best using
CC as `apr --cc` throughout.
>
> I have code that links to APR fine on MacOSX, but build the same code on
> Solaris v2.8 and it bombs out with the error below. I am pretty sure I am
> using the wrong apr-config flags, but without knowing what the right flags
> are supposed to be I am pretty stuck:
>
> cc -DHAVE_CONFIG_H -I. -I. -I../../src/include
> -I/udd001/app/spread/usr/include/apr-0 -g -c -o diablo-diablo.o `test -f
> 'diablo.c' || echo './'`diablo.c
> cc -g -o diablo -L/udd001/app/spread/usr/lib -lapr-0 -lsendfile -lrt
> -lm -lsocket -lnsl -lresolv -lpthread -ldl diablo-diablo.o
> ild: (bad file) archive subfile #1 in
> /udd001/app/spread/usr/lib/libapr-0.a is a file of unknown type
That's pretty weird. You weren't mixing 64-bit and 32-bit objects or
anything? "ar -tv" output on libapr-0.a show anything other than .o
files in the archive?
joe