[CMake] static library linking problem

Vojtěch Novák vonovak at gmail.com
Tue May 14 19:05:13 EDT 2013


hello,

I'm working on a C++ package for ROS (robot operating system) that uses a C
library libccv.a. ROS uses CMake which is why I am asking here. Asking at
ROS answers did not help and I am totally stuck.

here is the relevant part of my CMakeLists.txt:

set(SOURCES src/${PROJECT_NAME}.cpp src/RosDispatcher.cpp src/Text2D.cpp
src/TDetector.cpp src/TRecognizer.cpp)
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH}
"${CMAKE_SOURCE_DIR}/cmake/Modules/")

find_package(CCV REQUIRED)
include_directories(${CCV_INCLUDE_DIR})
set(LIBS ${LIBS} ${CCV_LIBRARY})

find_package(JPEG REQUIRED)
include_directories(${JPEG_INCLUDE_DIR})
set(LIBS ${LIBS} ${JPEG_LIBRARY})

find_package(PNG REQUIRED)
include_directories(${PNG_INCLUDE_DIR})
set(LIBS ${LIBS} ${PNG_LIBRARY})

message(STATUS "linked libs: ${LIBS}")

rosbuild_add_executable(${PROJECT_NAME} ${SOURCES})
target_link_libraries(${PROJECT_NAME} ${LIBS})


I am getting this error:

undefined reference to `ccv_read_impl(...)'
and more undefined references to the stuff from the library


libccv.a comes with a header file ccv.h and it depends on libjpeg and
libpng.

I wrote my own FindCCV.cmake to find the library and put it into
${CMAKE_SOURCE_DIR}/cmake/Modules/, together with finders for jpeg and png.
As far as I know, all three are found successfully (the REQUIRED keyword
doesn't stop compilation and there are correct address entries in
CMakeCache). The libraries are in correct order ccv, jpeg, png (ccv depends
on them).

here <http://pastebin.com/iye7iuqX> [pastebin] is output of the compilation
here <http://pastebin.com/f6WK1A1x> is my FindCCV.cmake

Please, what am I doing wrong?

Any help is very greatly appreciated, thanks!
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.cmake.org/pipermail/cmake/attachments/20130514/44db730f/attachment.htm>


More information about the CMake mailing list