[CMake] Linking Problems w. CMake 2.4 and MinGW32

Brad King brad.king at kitware.com
Fri Sep 1 10:00:55 EDT 2006


hendrik at darkon.info wrote:
> although I am aware of the fact that the following issue was already discussed by some fellows several months ago on this list, no solution was found there, so I'm just asking this again:
> 
> When generating Makefiles with CMake 2.4 for the MingW environment, the build process runs fine until it gets to linkage of an executable. CMake insists on adding the full file name for external libraries, while ld expects the -l parameter not to contain any file extension or prefix. E.g. for linkage with boost_regex-mgw.lib, the correct calling syntax would be -lboost_regex-mgw, but CMake produces -lboost_regex-mgw.lib, which leads to
> an error.
> 
> I haven't found a solution for this so far. Explicitly setting the appropiate library variable to DRIVE:\PATH\libname instead of DRIVE:\PATH\libname.lib or DRIVE:\PATH\libname.dll does not work, since CMake appends the .lib extension here by itself.
> 
> Anyone here could provide me with a solution for this?

I just tried

ADD_EXECUTABLE(foo foo.cxx)
TARGET_LINK_LIBRARIES(foo bar.lib)

and I got a "-lbar" on the link line from CMake 2.4.3 with the "MSYS
Makefiles" and "MinGW Makefiles" generators.

Try adding

MESSAGE("CMAKE_EXTRA_LINK_EXTENSIONS=[${CMAKE_EXTRA_LINK_EXTENSIONS}]")

to your code to see if the variable is set to ".lib" as it is supposed
to be on MinGW and MSYS generators.

-Brad


More information about the CMake mailing list