LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 03-16-2010, 02:23 PM   #1
catallergy
LQ Newbie
 
Registered: Mar 2010
Posts: 5

Rep: Reputation: 0
Bdynamic and Bstatic in g++/gcc


Hi

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.
 
Old 03-16-2010, 05:08 PM   #2
ForzaItalia2006
Member
 
Registered: Dec 2009
Location: Walldorf, Germany
Distribution: (X)Ubuntu, Arch, Gentoo
Posts: 205

Rep: Reputation: 67
Hey,

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++!

- Andi -
 
Old 03-22-2010, 05:40 PM   #3
CoderMan
Member
 
Registered: Jan 2009
Location: Gemini Capsule 25164
Distribution: Gentoo
Posts: 375
Blog Entries: 24

Rep: Reputation: 43
Quote:
Originally Posted by catallergy View Post
Hi

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?

http://www.indicium.us/site_blog/201...c-linking.html
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
gcc (GCC) 4.3.2 20081105 (Red Hat 4.3.2-7) compilation error adhesh_19 Red Hat 0 01-05-2010 05:34 AM
Installing vmware on Open Suse 11.1 - Requires original gcc 4.32 - gcc now 4.3 cyclops.matrix Linux - Software 2 08-31-2009 02:52 PM
yum install gcc doesn't set the lastest gcc ver 4.3.x kim,jw Linux - Newbie 3 12-22-2008 11:51 PM
gcc wont install, 'failed dependencies: glibc-devel is needed by gcc-3.3.3-41' TdlSnare SUSE / openSUSE 3 11-29-2004 02:13 PM
export CC=/usr/bin/gcc-3.2 - switch gcc version? ferreter Linux - Software 1 08-20-2003 12:07 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 04:13 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration