zzz
zzz

Reputation: 123

How might excess links/libraries affect the executable output during compilation?

For instance, if I were to link the object "example.o" with

-L/usr/X11R6/lib -L/usr/local/lib -lGL -lGLU -lm -lglut -lGLEW -lglfw3 -lX11 -lXxf86vm -lXrandr -lpthread -lXi -ldl -lXcursor -lXinerama

and the output executable compiled just as well (and perceivably functioned just as well) as when linked only with

-lGL -lm -lglfw3

how then might the excessive linkages of the former compilation affect an executable for the end user (if at all)? Load/run times? For larger programs (understanding that "example.o" is rather small)?

This question may be for my own edification, admittedly.

Upvotes: 1

Views: 32

Answers (1)

Johan Boulé
Johan Boulé

Reputation: 2090

If your compiler driver is passing the "--as-needed" option to the linker by default, then this will make no difference in the resulting binary because the linker will drop the unneeded library dependencies.

The Debian wiki as an extensive article on this: Debian DSO Linking.

Upvotes: 1

Related Questions