[CMake] Problems with linking on MinGW?

Ryan Pavlik rpavlik at iastate.edu
Tue Jun 15 11:58:28 EDT 2010


On 06/15/2010 09:54 AM, Jesse Perla wrote:
> I am using CMake 2.8.1 on Windows 7.  I have MinGW installed with GCC 4.5
>
> I have successfully compiled a library with a MinGW and cmake.  The 
> full path to the library is: c:\working\etk_binaries\libetk-mgw45.a
>
> However, when I want to link this file into an executable (no need to 
> have the CMake dependencies, etc. in projects) it can't seem to find 
> this file.
> My cmakelists.txt is:
>   cmake_minimum_required(VERSION 2.6)
>   set(PROJECT_NAME  "test" )
>   set(SRCS test.cpp )
>   project(${PROJECT_NAME})
>   add_executable(${PROJECT_NAME} ${SRCS})
>
>   link_directories( "c:/working/etk_binaries")
>   target_link_libraries(${PROJECT_NAME} libetk-mgw45)
>
>
> The error I get is:
>
> c:\MinGW\bin/ld.exe: cannot find -llibetk-mgw45
> collect2: ld returned 1 exit status
> mingw32-make[2]: *** [test.exe] Error 1
> mingw32-make[1]: *** [CMakeFiles/test.dir/all] Error 2
>
>
> Any ideas on what I have done wrong?
>
> Thanks,
> Jesse
>

You should use or create a FindXXX.cmake module that locates the desired 
library and include files.  Then, you should do something like
target_link_libraries(${PROJECT_NAME} ${ETK_LIBRARIES})

(The issue you are having is because you aren't using the full path to 
the library.)

Ryan


-- 
Ryan Pavlik
HCI Graduate Student
Virtual Reality Applications Center
Iowa State University

rpavlik at iastate.edu
http://academic.cleardefinition.com

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.cmake.org/pipermail/cmake/attachments/20100615/1eb0ad2b/attachment.htm>


More information about the CMake mailing list