Re: Change to DSO-linking semantics of the compiler

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

 



> According to notting and the experimentation that I did after the FESCo
> meeting, the shared libraries bring in any libraries that they depend on.
> However, if the application linking to the shared library also requires the
> third shared library but doesn't explicitly link it then the link will fail.

That's right.

> ie:
> 
> Given:
> libfoo requires libbar.
> This is used to link: gcc -o libfoo.so -lbar foo.o
> libfoo.so contains the dependency on libbar.
> 
> Scenario 1:
> /usr/bin/baz depends on symbols in libfoo but not libbar.
> This can be used to link: gcc -o baz -lfoo baz.o
> The link succeeds and the resulting /usr/bin/baz links to both libfoo.so and
> libbar.so as expected.
> 
> Scenario 2:
> /usr/bin/baz depends on symbols in both libfoo and llibbar
> This fails to link because of missing libbar: gcc -o baz -lfoo baz.o
> This succeeds: gcc -o baz -lfoo -lbar baz.o
> 
> Roland, can you clarify that this is indeed how things are supposed to work?

Yes, that's correct.  A common example seems to be -lm.  If you use 'pow'
(or whatever), then you should pass -lm.  If some other library you use
happens to use -lm at the moment, that doesn't mean you shouldn't pass -lm
when you are using some API symbols from -lm.

> Also... it took me quite a while to come up with the command line flags on
> F12 that would allow me to test this (I think I had to get gcc to show me
> the linker invokation it used and then run those linker lines  with my
> modifications), can you tell us what command line flags let us test out the
> differences in behaviour on F12?

You can always pass extra linker flags through gcc with -Wl,--foo.
You can give as many of these as you like, and -Wl,a,b is the same
as -Wl,a -Wl,b (both mean to pass "a" and "b" arguments on to ld).

On F12 (or F11) you can use 'gcc -Wl,--no-add-needed' to get the
new linking semantics.  e.g.,

	.../configure LDFLAGS=-Wl,--no-add-needed

probably works on many packages if you want to try a manual build of
something this way.


Thanks,
Roland
-- 
devel mailing list
devel@xxxxxxxxxxxxxxxxxxxxxxx
https://admin.fedoraproject.org/mailman/listinfo/devel

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Fedora Announce]     [Fedora Kernel]     [Fedora Testing]     [Fedora Formulas]     [Fedora PHP Devel]     [Kernel Development]     [Fedora Legacy]     [Fedora Maintainers]     [Fedora Desktop]     [PAM]     [Red Hat Development]     [Gimp]     [Yosemite News]
  Powered by Linux