[CMake] Create executable with no dynamic dependency at all

Denis Scherbakov denis_scherbakov at yahoo.com
Thu May 7 03:59:21 EDT 2009


Jean-Pierre,

I am not sure, how you get -Wl,-Bstatic and so on. Here is how I get static executable:

$ /usr/bin/c++  -O2 -fomit-frame-pointer -fPIC -s -static \
CMakeFiles/DispatcherExe.dir/DispatcherMain.cc.o \
-o DispatcherExe \
-rdynamic ../../Generic/libGeneric.a \
../../CorbaUtil/libCorbaUtil.a -lmico2.3.13 -lmicocoss2.3.13 -lssl -lcrypto -lpthread -ldl

$ ldd DispatcherExe
        not a dynamic executable

Here is how I link it:

ADD_LIBRARY(Generic STATIC ${GENERIC_SRCS})

ADD_LIBRARY(CorbaUtil STATIC ${CORBAUTIL_SRCS})
TARGET_LINK_LIBRARIES(CorbaUtil  ${MICO_LIBRARY} ${MICO_COSS_LIBRARY} ssl crypto pthread dl)

ADD_EXECUTABLE(DispatcherExe  ${OPERDISPATCHER_SRCS})
TARGET_LINK_LIBRARIES(DispatcherExe  CorbaUtil Generic)

Denis

--- On Wed, 5/6/09, Jean-Pierre Bergamin <james at junisphere.net> wrote:

> From: Jean-Pierre Bergamin <james at junisphere.net>
> Subject: [CMake] Create executable with no dynamic dependency at all
> To: cmake at cmake.org
> Date: Wednesday, May 6, 2009, 11:59 PM
> Hello CMake users
> 

> So my question is how to avoid any dynamic linking at all.
> I found this bug report
> http://www.vtk.org/Bug/view.php?id=1644 that says
> that this has been implemented - but how?



      


More information about the CMake mailing list