[Cmake] command to build dynamic lib changed causing my VXL build to brea k

Brad King brad.king at kitware.com
Sat Jan 12 20:57:29 EST 2002


Fred,

> Sometime over the past week or two CMake started producing makefiles
> that use the "-shared -nostdlib" options instead of "-Wl,-G" to link
> objects into a shared library (*.so).  With this change all of VXL
> still builds for me, but just about all executables produced in the
> VXL tree stop with a Bus Error immediately after starting.  
> Everything build fine, but nothing runs.  Strange.
We recently switched the flags from -Wl,-G to -shared -nostdlib to solve
other problems.  The -shared flag is the correct choice..."-Wl,-G" tells
the C++ compiler to pass the "-G" option to the linker, which tells it to
create a shared library.  However, the C++ compiler then does not know
that the code it is generating is going into a shared library, so it
doesn't put in the correct static data initialization code (to call
constructors of static data, etc).  The -shared option tells the compiler
to put in the proper init code, and automatically causes it to pass the -G
option on to the linker.

Have you done a complete re-build of VXL in a clean directory?  Your
problems may be caused by some .o files or libraries being built with the
old flags, and some with the new.

-Brad




More information about the CMake mailing list