This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
Re: [Newbie question] compilation,, linking and general libbfd/libiberty question
- From: Nicholas Clifton <nickc at redhat dot com>
- To: Florian Mayer <mayerflorian at me dot com>, binutils at sourceware dot org
- Date: Mon, 23 Feb 2015 15:56:44 +0000
- Subject: Re: [Newbie question] compilation,, linking and general libbfd/libiberty question
- Authentication-results: sourceware.org; auth=none
- References: <54CC30FE dot 3000306 at me dot com>
Hi Florian,
$ gcc -o tbfd tbfd.c /usr/lib/libiberty.a /usr/lib/libbfd.a -liberty
-lbfd -ldl
/usr/lib/libbfd.a(compress.o): In function `bfd_compress_section_contents':
(.text+0x2c): undefined reference to `compressBound'
As you have discovered these symbols are provided by the z compression
library, so you need to include -lz on the command line.
Is there any additional introductory material that I could read.
Not really. The sources are the best reference. Although in this
particular case perhaps the easiest way to find out what was going wrong
would be to use the sources to build the binutils for an arbitrary
target (eg configure --target=x86_64-pc-linux-gnu) and then examine the
command line used to link in the bfd library when creating an executable.
PS: Sorry for the question, but why is the libiberty no independent
shared object? I read that it has historically and propably organically
grown, but I don't see why this is the reason for libiberty not beeing a
.so for it's own...
Actually it can be built as a shared library - just add
"--enable-shared" to the configure command line at the start. It is
just a historical thing that the default is a static library.
Cheers
Nick