[CMake] unnecessary linker options when compiling executables with mingw/gcc

Brad King brad.king at kitware.com
Thu Oct 2 09:28:13 EDT 2008


Werner Smekal wrote:
> recently I found out (make VERBOSE=1) that when an executable is
> compiled with MinGW Makefiles some linker options are in the command
> line, which should be in my opinion only necessary for libraries:
> 
> -Wl,--out-implib,libtest.dll.a
> -Wl,--major-image-version,0,--minor-image-version,0
> 
> I could reproduce this options with a simple test case (files attached).
> Compiling this project gives (MinGW Makefiles):
> 
> Linking C executable test.exe
> C:\DevZone\cmake-2.6.2-win32-x86\bin\cmake.exe -E cmake_link_script
> CMakeFiles\test.dir\link.txt --verbose=1
> C:\DevZone\MinGW-3.4.5\bin\gcc.exe     CMakeFiles\test.dir\test.c.obj -o
> test.exe -Wl,--out-implib,libtest.dll.a
> -Wl,--major-image-version,0,--minor-image-version,0

These options are necessary.  The image version does appear in windows
executables.  If any object file in the executable uses
__declspec(dllexport) on a symbol, an import library for the executable
will be built.  The --out-implib option is needed to specify its name.

> It doesn't seem to have any implications, apart maybe from this message:
>  http://www.mail-archive.com/cmake@cmake.org/msg15862.html

I missed that message before, and have just replied to it separately.
The problem in that case is trying to use Windows build rules for a
non-windows target environment while cross-compiling.

-Brad


More information about the CMake mailing list