Unix Programming - Conflict between static and dynamic libraries

This is Interesting: Free IT Magazines  
Home > Archive > Unix Programming > January 2005 > Conflict between static and dynamic libraries





You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

Author Conflict between static and dynamic libraries
Daniel Haude

2005-01-23, 5:50 pm

Hello folks,

I'm having problems building a GNU autoconf project which includes some
nonstandard libraries. The relevant part of my Makefile.am looks
like this:

lunchbox_LDFLAGS = -ljpeg \
`pkg-config --libs gthread-2.0` `sdl-config --libs` \
-lraw1394 -ldc1394_control -lavt1394

The program builds fine, but upon execution it complains about not
finding the libraries in the last line -- little wonder, as they only
exists as static versions on my system.

OK, so I just added -static to my ldflags, but then the program doesn't
link any more (dumping screenfuls of unfound symbols), probably because
the linker doesn't find static versions of
the *other* libs.

Then I looked at the actual linking command generated by make (without
-static):

gcc -g -O2 -W -Wall -g -Wno-unused `sdl-config --cflags` -o lunchbox
-ljpeg `pkg-config --libs gthread-2.0` `sdl-config --libs` -lraw1394
-ldc1394_control -lavt1394 main.o support.o common.o lunchbox_if.o
lunchbox_cb.o dc1394.o video.o movie.o yuyv_jpeg.o -Wl,--export-dynamic
-lgtk-x11-2.0 -lgdk-x11-2.0 -latk-1.0 -lgdk_pixbuf-2.0 -lm -lpangoxft-1.0
-lpangox-1.0 -lpango-1.0 -lgobject-2.0 -lgmodule-2.0 -ldl -lglib-2.0

The --export-dynamic caught my attention. I got rid of it, but it didn't
make any difference.

How can I solve this?

--Daniel



--
"With me is nothing wrong! And with you?" (from r.a.m.p)
David Schwartz

2005-01-23, 5:50 pm


"Daniel Haude" <haude@kir.physnet.uni-hamburg.de> wrote in message
news:slrncv83s9.jks.haude@kir.physnet.uni-hamburg.de...

> lunchbox_LDFLAGS = -ljpeg \
> `pkg-config --libs gthread-2.0` `sdl-config --libs` \
> -lraw1394 -ldc1394_control -lavt1394


> The program builds fine, but upon execution it complains about not
> finding the libraries in the last line -- little wonder, as they only
> exists as static versions on my system.


So link to the corresponding .a files instead. So replace '-lraw1394'
with 'raw1394.o' or 'raw1394.a'. Make the path right, of course.

DS


Heny Townsend

2005-01-23, 5:50 pm

David Schwartz wrote:
> "Daniel Haude" <haude@kir.physnet.uni-hamburg.de> wrote in message
> news:slrncv83s9.jks.haude@kir.physnet.uni-hamburg.de...
>
>
>
>
>
>
> So link to the corresponding .a files instead. So replace '-lraw1394'
> with 'raw1394.o' or 'raw1394.a'. Make the path right, of course.


That might work but (assuming gcc) wouldn't -Wl,-Bstatic and
-Wl,-Bdynamic be a cleaner thing to recommend? Use them to surround the
libraries you want to link statically, e.g.:

... -Wl,-Bstatic -lfoo -lbar -Wl,-Bdynamic ...


--
Henry Townsend
David Schwartz

2005-01-24, 5:53 pm


"Heny Townsend" <henry.townsend@not.here> wrote in message
news:LsCdnZ_RYrJUgWncRVn-hw@comcast.com...

> That might work but (assuming gcc) wouldn't -Wl,-Bstatic and -Wl,-Bdynamic
> be a cleaner thing to recommend? Use them to surround the libraries you
> want to link statically, e.g.:
>
> ... -Wl,-Bstatic -lfoo -lbar -Wl,-Bdynamic ...


I guess it would be cleaner, but I don't like command lines with
order-sensitive option flags.

DS


Heny Townsend

2005-01-24, 5:53 pm

David Schwartz wrote:

> "Heny Townsend" <henry.townsend@not.here> wrote in message
> news:LsCdnZ_RYrJUgWncRVn-hw@comcast.com...
>
>
>
>
> I guess it would be cleaner, but I don't like command lines with
> order-sensitive option flags.


Ummm ... a linker command line is inherently order-sensitive with or
without -B flags.

--
Henry Townsend
David Schwartz

2005-01-24, 8:48 pm


"Heny Townsend" <henry.townsend@not.here> wrote in message
news:_P-dnSOUCpmV9GjcRVn-1w@comcast.com...

> David Schwartz wrote:


[vbcol=seagreen]
[vbcol=seagreen]
[vbcol=seagreen]
> Ummm ... a linker command line is inherently order-sensitive with or
> without -B flags.


As you might imagine, I don't like that. It's sometimes a major pain to
find the right link order.

DS


Sponsored Links






Free braindumps | Software forum | Database administration forum

Copyright 2003 - 2008 webservertalk.com