This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Segfault on OpenMP program


On Wed, Apr 18, 2007 at 07:38:40PM +0200, Kenneth Hoste wrote:
> Is this only advised with parallel programs, or is it a general rule?
> In my research, I statically link all my benchmarks because that I  
> measure stuff about them using instrumentation on a bunch of computer  
> (which might have various OSs, OS versions, libc versions, ...).  
> Because we want to analyze the same dynamic executed code over and  
> over again (no matter on which machine the analysis is donne), I use  
> static linking.

General rule.  Statically linked programs are actually far more dependent
on the environment they are compiled in rather than less dependent,
please read e.g. http://people.redhat.com/drepper/no_static_linking.html

> - How can I easily dynamically link against libc, but statically link  
> with everything else? Currently, making everything statically linked  
> is easy: in the various makefiles I set CC="gcc -static". Is there a  
> similar 'trick' to link libc dynamically but everything else  
> statically? (I'm using GCC 4.1.2 if it matters)

The libraries which you want to link statically into the application
just mention between -Wl,-Bstatic ... -Wl,-Bdynamic on the command line.
So say 
gcc -o foo ..... -Wl,-Bstatic -lfoo -lbar -lbaz -Wl,-Bdynamic -ldl -lpthread
will link libfoo, libbar and libbaz into the application and libdl,
libpthread, libc dynamically.

	Jakub


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]