[CMake] Finding MinGW compiler libraries?

Bill Hoffman bill.hoffman at kitware.com
Sat Jul 26 22:58:19 EDT 2008


Bob Paddock wrote:
> On Saturday 26 July 2008 03:28:59 pm Miguel A. Figueroa-Villanueva wrote:
> 
>>> My project needs to link against C:\MinGW\lib\libuuid.a, amoung
>>> others, but it is not being found.
>>>
>>> I tried this:
>>>
>>> find_library( MinGW_Libraries uuid )
>> find_library(MinGW_Libraries uuid "C:/MinGW/lib")
>>
>> Does this work?
> 
> Yes it did, thank you.
> 
> That lead to the discovery that I also need libole32.a and/or libshell32.a
> When doing the same thing, the wrong ones are found:
> 
> MinGW_libole32 "C:/WINDOWS/system32/ole32.dll"
> MinGW_libshell32 "C:/WINDOWS/system32/shell32.dll"
> MinGW_libuuid "C:/MinGW/lib/libuuid.a"
> 

For system libraries like this it is often better to just link them in 
with -l.  The compiler should be able to find them if it is installed 
correctly.  There is a good chance CMake will get it wrong.   So, the 
correct CMake solution for system/compiler libraries is to just use the 
name of the library.

Something like this:

if(MINGW)
target_link_libraries(foo uuid ole32 shell32)
endif(MINGW)

-Bill


More information about the CMake mailing list