[CMake] Simple (?) lib linking question

William A. Hoffman billlist at nycap.rr.com
Fri Aug 4 20:37:42 EDT 2006


At 04:08 AM 8/4/2006, Anders Sundman wrote:
>Shouldn't the line:
>-> C:\MinGW\bin\g++.exe    -shared -o liba.dll -Wl,--out-implib,liba.dll.a "CMakeFiles/a.dir/a.obj" -lb
>
>also contain a -L switch since I have the line "LINK_DIRECTORIES(${TEST_SOURCE_DIR}/b)" in the cmake file for the "a"-lib?
>
>// Anders Sundman 

It is an ordering problem, you have this:

ADD_LIBRARY(liba SHARED liba.cpp)
INCLUDE_DIRECTORIES(${TEST_SOURCE_DIR}/libb)
LINK_DIRECTORIES(${TEST_SOURCE_DIR}/libb)
TARGET_LINK_LIBRARIES(liba libb)

The LINK_DIRECTORIES command has to come before the ADD_LIBRARY command.

-Bill



More information about the CMake mailing list