3

I am trying to compile a ROS-package from a friend with catkin under Ubuntu 14.04 and am getting the following error:

/usr/bin/ld: warning: libboost_system.so.1.49.0, needed by   
//usr/local/MATLAB/R2014a/bin/glnxa64/libut.so, may conflict with libboost_system.so.1.54.0
//usr/local/lib/libcvd.so: undefined reference to `TIFFWriteEncodedStrip@LIBTIFF_4.0'
//usr/local/lib/libcvd.so: undefined reference to `TIFFReadRGBAImageOriented@LIBTIFF_4.0'
//usr/local/lib/libcvd.so: undefined reference to `TIFFWriteScanline@LIBTIFF_4.0'
//usr/local/lib/libcvd.so: undefined reference to `TIFFGetField@LIBTIFF_4.0'
//usr/local/lib/libcvd.so: undefined reference to `TIFFClose@LIBTIFF_4.0'
//usr/local/lib/libcvd.so: undefined reference to `TIFFClientOpen@LIBTIFF_4.0'
//usr/local/lib/libcvd.so: undefined reference to `TIFFGetFieldDefaulted@LIBTIFF_4.0'
//usr/local/lib/libcvd.so: undefined reference to `TIFFStripSize@LIBTIFF_4.0'
//usr/local/lib/libcvd.so: undefined reference to `TIFFSetField@LIBTIFF_4.0'
//usr/lib/x86_64-linux-gnu/libharfbuzz.so.0: undefined reference to `FT_Face_GetCharVariantIndex'
//usr/local/lib/libcvd.so: undefined reference to `TIFFSetErrorHandler@LIBTIFF_4.0'
//usr/local/lib/libcvd.so: undefined reference to `TIFFReadScanline@LIBTIFF_4.0'
//usr/lib/x86_64-linux-gnu/libharfbuzz.so.0: undefined reference to `FT_Get_Advance'
collect2: error: ld returned 1 exit status

I have libcvd installed and also libtiff4-dev. Has anybody any idea, how to solve that issue?

Thanks a lot,

snow

EDIT: As suggest I include the CMakeLists.txt:

cmake_minimum_required(VERSION 2.8.3)
project(test)
set (test_VERSION "0.0.1")


find_package(OpenCV REQUIRED)

find_package(catkin REQUIRED COMPONENTS
  test_core
  cv_bridge
  image_transport
  roscpp
)

find_package(tracker)

set (CMAKE_CXX_FLAGS "-DNDEBUG -DNTIMING -DNRUN_UNIT_TESTS -g -O0 -std=c++11")

catkin_package(
  INCLUDE_DIRS include
)


include_directories (include
  ${CMAKE_CURRENT_SOURCE_DIR}/include
  ${tracker_INCLUDE_DIRS}
  ${TRIANGULATION_INCLUDE_DIRS}
  ${OPENCV_INCLUDE_DIRS}
)

include_directories(/usr/local/MATLAB/R2014a/extern/include)

include_directories (SYSTEM
  ${catkin_INCLUDE_DIRS}
)

set (SOURCE
  src/test/main.cc
  src/test/rosbridge.cc
  src/test/core.cc
)

add_executable (test ${SOURCE})

target_link_libraries(test
  /lib/x86_64-linux-gnu/libssl.so.1.0.0
  /lib/x86_64-linux-gnu/libcrypt.so.1
  /lib/x86_64-linux-gnu/libcrypto.so.1.0.0
  /usr/local/MATLAB/R2014a/bin/glnxa64/libmx.so
  /usr/local/MATLAB/R2014a/bin/glnxa64/libeng.so
  /usr/local/MATLAB/R2014a/bin/glnxa64/libmat.so
  /usr/local/MATLAB/R2014a/bin/glnxa64/libut.so
  ${OpenCV_LIBS}
  ${tracker_LIBRARIES}
  cvd
  ${catkin_LIBRARIES}
  ${TRIANGULATION_LIBRARIES}
)
snow
  • 71
  • 10
  • Is the library linked with the executable? Please post the corresponding `CMakeLists.txt`, the problem is probably located in this file. – luator Apr 21 '15 at 06:58
  • I edited my previous post and add the `CMakeLists.txt` – snow Apr 21 '15 at 17:39

2 Answers2

1

Just linking cvd seems to not work in your case. CMake comes with the great find_package feature, though, so let's use it:

  1. Add find_package(CVD REQUIRED) at the top of the file
  2. Add ${CVD_INCLUDE_DIRS} to include_directories
  3. Replace cvd in target_link_libraries with ${CVD_LIBRARIES}

This may not work immediately but throw an error like "FindCVD.cmake not found". This is a script that searches your file system for the actual location of this library on your system and stores the paths to the variables used above. Many libraries already bring such an file themselves, but if this is not the case you have to provide it manually. In most cases you don't have to write this file yourself, though, as there is usually a bunch of open source projects, that already created such a file, which you can reuse (for example here). Just google "FindCVD.cmake" to find them.

Once you have this file:

  1. Create a new subdirectory called "cmake" in your project and store the file there.
  2. Add set(CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake) at the top of your CMakeLists.txt (before the find_package call!)

Now it should hopefully work :)

luator
  • 4,769
  • 3
  • 30
  • 51
  • Thank you very much for your help and that very well explained answer. Unfortunately I am still getting the exact same error :-( – snow Apr 22 '15 at 16:39
  • 1
    Hm, just a guess, but maybe you have to explicitly link against libtiff as well (using the same procedure like above). – luator Apr 22 '15 at 19:55
  • That's what I was thinking as well, therefore I tried to find a `FindLibTiff.cmake` file. The only one I found was this one here: https://github.com/hobit03/OGS_PVS/blob/master/CMakeConfiguration/FindLibTiff.cmake But then I am getting just the following error by trying to compile: `CMake Error at test/cmake/FindLibTiff.cmake:10 (include): include could not find load file ` – snow Apr 22 '15 at 20:15
  • @snow: The LibFindMacros module used there is not part of cmake itself, but can be downloaded [here](https://github.com/Tronic/cmake-modules). Simply store the file in the same directory as the Find*.cmake files. – luator Apr 23 '15 at 07:05
  • I included the LibFindMacros module from [here](http://gnuradio.org/redmine/projects/gnuradio/repository/revisions/accb9f2fe8fd8f6a1e114adac5b15304b0e0012d/entry/cmake/Modules/LibFindMacros.cmake). Now I do not get any errors from the `FindLibTiff.cmake`, but still have the origin issue :-( – snow Apr 23 '15 at 17:02
  • what do you think about [this](http://stackoverflow.com/questions/29272497/linking-error-with-libopencv-highgui-so-under-ubuntu-14-04-strange-result-wit/29837433#29837433) ? Is that maybe the same issue what I have and it is not working under Ubuntu 14.04? – snow Apr 24 '15 at 02:03
  • To be honest, I can only guess from now on. It seems, that libtiff4 is problematic on Ubuntu 14.04. Can you maybe use libtiff5 instead? – luator Apr 25 '15 at 08:14
  • I guess not, but I am trying to figure out a way around. If I found a solution I will post it – snow Apr 27 '15 at 17:36
1

I fixed it!

You have to link against the libtiff lib in your lib folder like this:

target_link_libraries(test
  .
  .
  .
  /usr/lib/x86_64-linux-gnu/libtiff.so.5  
  .
  .
  .
)
snow
  • 71
  • 10