Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error linking TIFF on Ubuntu #20

Open
NikkittaP opened this issue Jun 27, 2019 · 6 comments
Open

Error linking TIFF on Ubuntu #20

NikkittaP opened this issue Jun 27, 2019 · 6 comments

Comments

@NikkittaP
Copy link

I use libgeotiff 1.5.1 and libtiff 4.0.10.
To build everything I use CMake and make.

TIFF:
cmake -G 'Unix Makefiles' ../../ -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=/home/nikita/OSG/test_osg/install/libtiff/Release -DZLIB_INCLUDE_DIR=/home/nikita/OSG/test_osg/install/zlib/Release/include/ -DZLIB_LIBRARY_RELEASE=/home/nikita/OSG/test_osg/install/zlib/Release/lib/libz.so -DJPEG_INCLUDE_DIR=/home/nikita/OSG/test_osg/install/libjpeg/Release/include/ -DJPEG_LIBRARY=/home/nikita/OSG/test_osg/install/libjpeg/Release/lib/libjpeg.so

libgeotiff:
cmake -G 'Unix Makefiles' ../../ -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=/home/nikita/OSG/test_osg/install/libgeotiff/Release -DWITH_UTILITIES=OFF -DWITH_JPEG=ON -DWITH_TIFF=ON -DWITH_ZLIB=ON -DPROJ_INCLUDE_DIR=/home/nikita/OSG/test_osg/install/proj/Release/include/ -DPROJ_LIBRARY=/home/nikita/OSG/test_osg/install/proj/Release/lib/libproj.so -DZLIB_INCLUDE_DIR=/home/nikita/OSG/test_osg/install/zlib/Release/include/ -DZLIB_LIBRARY_RELEASE=/home/nikita/OSG/test_osg/install/zlib/Release/lib/libz.so -DJPEG_INCLUDE_DIR=/home/nikita/OSG/test_osg/install/libjpeg/Release/include/ -DJPEG_LIBRARY=/home/nikita/OSG/test_osg/install/libjpeg/Release/lib/libjpeg.so -DTIFF_INCLUDE_DIR=/home/nikita/OSG/test_osg/install/libtiff/Release/include/ -DTIFF_LIBRARY_RELEASE=/home/nikita/OSG/test_osg/install/libtiff/Release/lib/libtiff.so

And while configuring CMake for geotiff I get the following error:

Found TIFF: /home/nikita/OSG/test_osg/install/libtiff/Release/lib/libtiff.so.5.4.0 (found version "4.0.10") 
CMake Error at CMakeLists.txt:182 (MESSAGE):
  Failed to link with libtiff - TIFFOpen function not found

The same sources on Windows with CMake and MSVC 2015 are built properly with no errors.

@NikkittaP
Copy link
Author

I'm still facing the same problem on Ubuntu 18.04. Any ideas?

@NikkittaP
Copy link
Author

Oookaay, here is my solution for now:

In the main CMakeLists.txt I commented out lines 179-189.
These lines checks functions in TIFF library and somehow it fails on Linux.
I will add more info if I have any problems while using this built libgeotiff library.

@attilaolah
Copy link

attilaolah commented Feb 22, 2021

I think this can be fixed by adding this line to CMakeLists.txt:

cmake_policy(SET CMP0075 NEW)

Specifically, the CMake checks don't seem to honor the CMAKE_REQUIRED_LIBRARIES. This causes failure when you try to link against libraries on your system.

@attilaolah
Copy link

Another option is to pass -DCMAKE_TRY_COMPILE_TARGET_TYPE=STATIC_LIBRARY to cmake.

@lastant
Copy link

lastant commented Jul 13, 2023

For me this happened because cmake was looking for libtiff using FIND_PACKAGE and found it, but only the variables TIFF_FOUND, TIFF_DIR, TIFF_VERSION were set, the variable TIFF_LIBRARIES was not, but was needed. I actually had to explicitly set the libraries in the /usr/share/cmake-3.22/Modules/CheckFunctionExists.cmake file to circumvent the issue.

@mathstuf
Copy link

Yes, the CMake package generated by libtiff upstream does not provide TIFF_LIBRARIES, so nothing ends up being passed to the try_compile for linking.in order to pass. The check needs reworked to handle this case. Something like this may be fine:

if (NOT TIFF_LIBRARIES AND TARGET TIFF::tiff)
  get_property(TIFF_LIBRARIES TARGET TIFF::tiff PROPERTY LOCATION)
  # request a `STATIC` library in `try_compile` as dependent libraries are not provided this way?
endif ()

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants