[CMake] statically linked executables

Daniel Rueckert dr at doc.ic.ac.uk
Wed Nov 28 16:57:01 EST 2007


Bill Hoffman wrote:
> Daniel Rueckert wrote:
>> Hi,
>>
>> I am trying to build some statically linked executables on a linux
>> box. I have added the "-static" option to the linker flags and specified
>> static link libraries but for some reason cmake still adds the option
>> "-Wl,-Bdynamic" flag to the linker options. Is there any way around this?
>>
>> Thanks, Daniel
> 
> Sounds like you might have some explicit shared libraries linked into 
> you project with full paths.
> 
> -Bill
> 

Not explicitly. The shared libraries are -lSM, -lICE (part of X11 I believe)
and -lm. I have not found any way how to change them into static libraries
in cmake. I have attached the linking command generated by cmake:

/usr/bin/c++    -fno-const-strings -ffloat-store -Wall -O2  -fPIC -static 
"CMakeFiles/binarize.dir/binarize.o"   -o ../bin/binarize -rdynamic 
-L/vol/vipdata/project/linux-ubuntu-static/lib 
-L/vol/vipdata/packages/Mesa-6.5/lib -Wl,-Bstatic -lz -lfltk_images -lfltk 
-lfltk_gl -lfltk_forms -Wl,-Bdynamic -lSM -lICE -Wl,-Bstatic -lX11 -lXext 
-Wl,-Bdynamic -lm -Wl,-Bstatic -lglut -lXmu -lXi -lGLU -lGL -Wl,-Bdynamic -lSM 
-lICE -Wl,-Bstatic -lX11 -lXext -lznz -lniftiio -lsegmentation++ 
-lregistration++ -ltransformation++ -lcontrib++ -limage++ -lgeometry++ 
-lcommon++ -lrecipes -lcontrib++ -limage++ -lgeometry++ -lcommon++ -lrecipes 
-ltransformation++ -lregistration++ -lsegmentation++ -lniftiio -lznz -lz 
-lfltk_images -lfltk -lfltk_gl -lfltk_forms -Wl,-Bdynamic -lSM -lICE 
-Wl,-Bstatic -lX11 -lXext -Wl,-Bdynamic -lm -Wl,-Bstatic -lglut -lXmu -lXi -lGLU 
-lGL -Wl,-Bdynamic -lSM -lICE -Wl,-Bstatic -lX11 -lXext -Wl,-Bdynamic 
-Wl,-rpath,/vol/vipdata/project/linux-ubuntu-static/lib:/vol/vipdata/packages/Mesa-6.5/lib

I would be grateful for any suggestions.

Daniel

-- 
Daniel Rueckert, Ph.D.
Department of Computing
Imperial College London
180 Queens' Gate                         Tel: +44 20 7594 8333
London SW7 2AZ                           Fax: +44 20 7581 8024
mailto:D.Rueckert at imperial.ac.uk         http://www.doc.ic.ac.uk/~dr


More information about the CMake mailing list