[CMake] shared library with CMake in kdevelop4

David Cole david.cole at kitware.com
Mon Jan 16 09:35:19 EST 2012


On Mon, Jan 16, 2012 at 9:34 AM, David Cole <david.cole at kitware.com> wrote:
> On Mon, Jan 16, 2012 at 8:38 AM,  <pasparis at noos.fr> wrote:
>>
>> I am new with kdevelop and cmake so apologize for this pretty naive
>> question, I create in kdevelop a proj3 project and want to link a library so
>> I create a second project projA within the proj3 directory
>>
>> the projA CMakelist is
>>
>> project(proja)
>> set( lib_SOURCES Execute_Msg.cpp )
>> add_library(proja ${lib_SOURCES} )
>>
>> the proj3 CMakelist is
>>
>> cmake_minimum_required(VERSION 2.8)
>> project(proj3)
>> link_directories(/pascal/pKD3/proj3/projA/build)
>> add_executable(proj3 main.cpp)
>> target_link_libraries(proj3 libproja)
>>
>> there is a libproja file in the /pascal/pKD3/proj3/projA/build directory, so
>> I don't understand why I get the message /usr/bin/ld: cannot find -llibproja
>>
>> thanks for help
>>
>
> The second arg to target_link_libraries should be a CMake target name
> or the full path to a library file. In this case, it should be:
>
>  target_link_libraries(proj3 proja)
>
> since proja is a CMake target name. If it were a full path to a
> library file, it might be something like:
>
>  target_link_libraries(proj3 /path/to/libproja.a)
>
>
> HTH,
> David


And the call to link_directories is unnecessary. In either case.


More information about the CMake mailing list