I tried your suggestion by setting SET_TARGET_PROPERTIES (bbb PROPERTIES LINK_FLAGS "-static -lc -lm -L/usr/local/lib/")
The result is the same i.e. the executable generated is not completely static. Still has shared library dependencies. The output generated after doing ldd bbb is libz.so.2 => /lib/libz.so.2 (0x28233000) libm.so.3 => /lib/libm.so.3 (0x28243000) libc.so.5 => /lib/libc.so.5 (0x2825e000) Regards, Ajay On Friday 08 June 2007 15:08, Alan W. Irwin wrote: > On 2007-06-08 14:37-0400 Ajay Divekar wrote: > > I am trying to create a static executable and for that I have already > > defined using ADD_Definitions the -static option. > > > > But after it is build and when I do > > ldd bbb (where bbb is the executable that was just generated) > > > > The output of the above command is > > > > libz.so.3 => /lib/libz.so.3 (0x281df000) > > libstdc++.so.6=> > > /usr/local/lib/gcc/i386-portbld-freebsd6.2/3.4.6/libstdc++.so.6 libm.so.4 > > => /lib/libm.so.4 (0x282b1000) > > libc.so.6 => /lib/libc.so.6 (0x282c7000) > > libgcc_s.so.1=> > > /usr/local/lib/gcc/i386-portbld-freebsd6.2/3.4.6/libgcc_s.so.1 libz.so.2 > > => /lib/libz.so.2 (0x2814f000) > > libm.so.3 => /lib/libm.so.3 (0x2815f000) > > libc.so.5 => /lib/libc.so.5 (0x2817a000) > > > > I want my executable to be static as this will make it completely > > platform independent. > > > > All these are system libraries and some of them are gcc releated. Is > > there anyway to create a static library library without any shared > > library dependency. > > Let me make a general comment first. Virtually every platform has a linker > option for building static executables. For example, on Linux see the > -Bstatic (or -static) linker option documented in 'man ld'. Once you have > decided what linker option you need for static executables on your > platform(s), then you have to tell cmake about it. > > Now to get specific, I don't think you specified the -static linker option > correctly above when you specified -static with ADD_DEFINITIONS. Use > -DCMAKE_VERBOSE_MAKEFILE=ON to see exactly where that -static option is > being used. My guess is it would just be the compile stage and not the > link stage. I suggest you try the LINK_FLAGS property of > SET_TARGET_PROPERTIES, instead. > > Alan > __________________________ > Alan W. Irwin > > Astronomical research affiliation with Department of Physics and Astronomy, > University of Victoria (astrowww.phys.uvic.ca). > > Programming affiliations with the FreeEOS equation-of-state implementation > for stellar interiors (freeeos.sf.net); PLplot scientific plotting software > package (plplot.org); the libLASi project (unifont.org/lasi); the Loads of > Linux Links project (loll.sf.net); and the Linux Brochure Project > (lbproject.sf.net). > __________________________ > > Linux-powered Science > __________________________ -- Ajay Divekar System Developer Guardian Technologies International Tel No : 703-481-4882 _______________________________________________ CMake mailing list CMake@cmake.org http://www.cmake.org/mailman/listinfo/cmake