Undefined references to tiff library

asked 2020-10-31 09:13:50 -0600

I installed OpenCV v.4.3.0 with the following commands (specifically with the BUILD_TIFF flag turned on):

cmake -D BUILD_TIFF=ON -DOPENCV_EXTRA_MODULES_PATH=../../opencv_contrib/modules ..

make

sudo make install

However when I try to compile in Clion I get a bunch of undefined references:

CMakeFiles/BuildingReconstruction.dir/src/file.cpp.o: In function `File::TIFFRead(std::__cxx11::basic_string<char, std::char_traits<char="">, std::allocator<char> >, cv::Mat&)':

/home/nairdap/BuildingReconstruction/src/file.cpp:24: undefined reference to `TIFFOpen'

/home/nairdap/BuildingReconstruction/src/file.cpp:29: undefined reference to `TIFFGetField'

/home/nairdap/BuildingReconstruction/src/file.cpp:30: undefined reference to `TIFFGetField'

/home/nairdap/BuildingReconstruction/src/file.cpp:31: undefined reference to `TIFFGetField'

/home/nairdap/BuildingReconstruction/src/file.cpp:32: undefined reference to `TIFFGetField'

/home/nairdap/BuildingReconstruction/src/file.cpp:33: undefined reference to `TIFFGetField'

I can ctrl-click in Clion on the references which brings me to the header file in /usr/include/x86_64-linux-gnu and when searching I found the same header file also in my opencv directory under /home/nairdap/opencv/3rdparty/libtiff.

My CMakeList looks as follows:

cmake_minimum_required(VERSION 3.15)

project(BuildingReconstruction)

set(CMAKE_CXX_STANDARD 14)

find_package(OpenCV REQUIRED)

include_directories(${OpenCV_INCLUDE_DIRS}) include_directories(data) include_directories(src)

add_executable(BuildingReconstruction data/cls.tiff data/dhm.tiff data/dsm.tiff data/dtm.tiff data/HappyFish.jpg data/tex.tiff src/anydbc.cpp src/anydbc.h src/anydbcpoint.h src/building.h src/dbscan.cpp src/dbscan.h src/dbscanpoint.h src/file.cpp src/file.h src/main.cpp src/ransac.cpp src/ransac.h src/renderer.cpp src/renderer.h)

target_link_libraries(BuildingReconstruction ${OpenCV_LIBS})

What am I missing here?

edit retag flag offensive close merge delete

Comments

What am I missing here?

  • did you build static or dynamic opencv libs ?
  • did you have cmake -DWITH_TIFF=ON ? check cmake output from building the opencv libs (esp. the Media IO section)
  • did you run a proper make install ?
  • is there a libtiff file /usr/local/lib/opencv4/3rdparty ?
  • data/cls.tiff data/dhm.tiff data/dsm.tiff data/dtm.tiff data/HappyFish.jpg data/tex.tiff --- none of this belongs here
  • please put clion and cmake aside for a moment, and try to build an ordinary g++ cmdline to compile your program
berak gravatar imageberak ( 2020-10-31 12:26:02 -0600 )edit
  • did you build static or dynamic opencv libs ? dynamic libs
  • did you have cmake -DWITH_TIFF=ON ? check cmake output from building the opencv libs (esp. the Media IO section) not the first time, enabled it and rerun it, Media IO section says TIFF: build (ver 42 - 4.0.10)
  • did you run a proper make install ? yes
  • is there a libtiff file /usr/local/lib/opencv4/3rdparty ? no, there's no opencv4, or any other opencv relevant folder in usr/local/lib. Only a bunch of libopencv_*.so files at usr/local/lib
nairdap gravatar imagenairdap ( 2020-11-07 03:38:29 -0600 )edit