ProgrammingThis forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
I cannot seem to find any good documentation on the role of
flags -Bdynamic and -Bstatic in g++. The man pages are not
very helpful either.
I found an example on the web:
"gcc object1.o object2.o -Wl,-Bstatic -lapplejuice -Wl,-Bdynamic -lorangejuice -o binary"
According to which -Bstatic instructs the linker to statically link
the applejuice library and to dynamically link the orangejuice
library. If orangejuice uses the applejuice library anywhere however,
the applejuice is also linked dynamically.
Is it correct to assume that this is correct and describes the true
functionality of those two flags in gcc? (ie: Bstatic and Bdynamic
are used for mixing static and shared libraries during linking)
Is it correct to assume that the same applies to g++ as well?
these two options are basically linker options and not part of gcc/g++. The gcc option -Wl,-Bdynamic indicates that -Bdynamic is passed down to the linker. But generally, your assumption is true, that -Bdynamic links against shared library (if the underlying OS and executable format support dynamic linking) and -Bstatic says to not link against shared libraries, though static libraries.
So, yes, these options could be used for both, gcc and g++!
I cannot seem to find any good documentation on the role of
flags -Bdynamic and -Bstatic in g++. The man pages are not
very helpful either.
I found an example on the web:
"gcc object1.o object2.o -Wl,-Bstatic -lapplejuice -Wl,-Bdynamic -lorangejuice -o binary"
According to which -Bstatic instructs the linker to statically link
the applejuice library and to dynamically link the orangejuice
library. If orangejuice uses the applejuice library anywhere however,
the applejuice is also linked dynamically.
Is it correct to assume that this is correct and describes the true
functionality of those two flags in gcc? (ie: Bstatic and Bdynamic
are used for mixing static and shared libraries during linking)
Is it correct to assume that the same applies to g++ as well?
Thanks a lot.
From the MAN GCC(1):
Quote:
-Bstatic
-Bdynamic
These options are passed down to the linker. They are defined for compatibility with Diab.
Diab is a compiler, I believe.
If you are interested in mixed static and dynamic linking with gcc, may I recommend my brief tutorial?
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.