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

Alan W. Irwin irwin at beluga.phys.uvic.ca
Thu Oct 2 14:13:23 EDT 2008


On 2008-10-02 09:53+0200 Werner Smekal wrote:

> Hi,
>
> 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
>
> It doesn't seem to have any implications, apart maybe from this message: 
> http://www.mail-archive.com/cmake@cmake.org/msg15862.html
>
> Any ideas?

Hi Werner:

I have no experience with MinGW linker, but it does seem strange that CMake
is setting what appears to be library flags for an executable. In what
follows I am going to assume you are right and concentrate on the
implementation question.

It appears from grepping through the 2.6.1 Platform directory that the
linker flags you are worried about are set in Windows-gcc.cmake.  Note, it
is likely non-MinGW platforms use that file since there is already
if(MINGW) logic there so any changes you make there should also be protected
by if(MINGW).



More information about the CMake mailing list