qtlinkercmakevtkprinter-control-language

Linking errors with qt pcl and vtk


I am trying to compile the PCL tutorial described here and I am facing these linking errors.

Linking CXX executable pcl_visualizer usr/lib/libpq.so.5: undefined reference to SSL_get_peer_certificate@OPENSSL_1.0.0' usr/lib/libvtkIO.so.5.8.0: undefined reference to TIFFReadDirectory@LIBTIFF_4.0' usr/lib/libpq.so.5: undefined reference to CRYPTO_num_locks@OPENSSL_1.0.0' usr/lib/libpq.so.5: undefined reference to SSL_CTX_use_certificate_chain_file@OPENSSL_1.0.0' usr/lib/libvtkIO.so.5.8.0: undefined reference to TIFFIsTiled@LIBTIFF_4.0' usr/lib/libpq.so.5: undefined reference to SSL_use_certificate_file@OPENSSL_1.0.0' usr/lib/libpq.so.5: undefined reference to ENGINE_free@OPENSSL_1.0.0' usr/lib/libpq.so.5: undefined reference toOPENSSL_config@OPENSSL_1.0.0' usr/lib/libpq.so.5: undefined reference to SSL_get_error@OPENSSL_1.0.0' usr/lib/libpq.so.5: undefined reference to SSL_use_PrivateKey_file@OPENSSL_1.0.0' usr/lib/libpq.so.5: undefined reference to X509_STORE_load_locations@OPENSSL_1.0.0' usr/lib/libvtkIO.so.5.8.0: undefined reference to TIFFDefaultStripSize@LIBTIFF_4.0' usr/lib/libvtkIO.so.5.8.0: undefined reference to TIFFReadTile@LIBTIFF_4.0' usr/lib/libpq.so.5: undefined reference toSSL_set_ex_data@OPENSSL_1.0.0' usr/lib/libvtkIO.so.5.8.0: undefined reference to TIFFWriteScanline@LIBTIFF_4.0' usr/lib/libvtkIO.so.5.8.0: undefined reference to_TIFFfree@LIBTIFF_4.0' usr/lib/libpq.so.5: undefined reference to SSL_read@OPENSSL_1.0.0' usr/lib/libvtkIO.so.5.8.0: undefined reference toTIFFGetField@LIBTIFF_4.0' usr/lib/libvtkIO.so.5.8.0: undefined reference to TIFFScanlineSize@LIBTIFF_4.0' usr/lib/libpq.so.5: undefined reference toX509_STORE_set_flags@OPENSSL_1.0.0' usr/lib/libpq.so.5: undefined reference to SSLv23_method@OPENSSL_1.0.0' usr/lib/libpq.so.5: undefined reference toENGINE_load_private_key@OPENSSL_1.0.0' usr/lib/libpq.so.5: undefined reference to X509_get_subject_name@OPENSSL_1.0.0' usr/lib/libpq.so.5: undefined reference toCRYPTO_set_id_callback@OPENSSL_1.0.0' usr/lib/libvtkIO.so.5.8.0: undefined reference to TIFFClose@LIBTIFF_4.0' usr/lib/libvtkIO.so.5.8.0: undefined reference toTIFFClientOpen@LIBTIFF_4.0' usr/lib/libpq.so.5: undefined reference to SSL_CTX_new@OPENSSL_1.0.0' usr/lib/libpq.so.5: undefined reference toSSL_CTX_get_cert_store@OPENSSL_1.0.0' usr/lib/libpq.so.5: undefined reference to SSL_check_private_key@OPENSSL_1.0.0' usr/lib/libvtkIO.so.5.8.0: undefined reference toTIFFGetFieldDefaulted@LIBTIFF_4.0' usr/lib/libpq.so.5: undefined reference to ENGINE_by_id@OPENSSL_1.0.0' usr/lib/libvtkIO.so.5.8.0: undefined reference toTIFFNumberOfDirectories@LIBTIFF_4.0' usr/lib/libpq.so.5: undefined reference to ERR_get_error@OPENSSL_1.0.0' usr/lib/libpq.so.5: undefined reference to CRYPTO_set_locking_callback@OPENSSL_1.0.0' usr/lib/libpq.so.5: undefined reference to SSL_load_error_strings@OPENSSL_1.0.0' usr/lib/libpq.so.5: undefined reference toSSL_new@OPENSSL_1.0.0' usr/lib/libpq.so.5: undefined reference to X509_NAME_get_text_by_NID@OPENSSL_1.0.0' usr/lib/libvtkIO.so.5.8.0: undefined reference toTIFFOpen@LIBTIFF_4.0' usr/lib/libpq.so.5: undefined reference to SSL_write@OPENSSL_1.0.0' usr/lib/libpq.so.5: undefined reference toX509_free@OPENSSL_1.0.0' usr/lib/libpq.so.5: undefined reference to SSL_CTX_load_verify_locations@OPENSSL_1.0.0' usr/lib/libvtkIO.so.5.8.0: undefined reference to TIFFReadRGBAImage@LIBTIFF_4.0' usr/lib/libpq.so.5: undefined reference to SSL_free@OPENSSL_1.0.0' usr/lib/libpq.so.5: undefined reference toSSL_ctrl@OPENSSL_1.0.0' usr/lib/libvtkIO.so.5.8.0: undefined reference to TIFFSetField@LIBTIFF_4.0' usr/lib/libpq.so.5: undefined reference toSSL_set_verify@OPENSSL_1.0.0' usr/lib/libpq.so.5: undefined reference to ENGINE_init@OPENSSL_1.0.0' usr/lib/libpq.so.5: undefined reference toSSL_set_fd@OPENSSL_1.0.0' usr/lib/libpq.so.5: undefined reference to SSL_connect@OPENSSL_1.0.0' usr/lib/libpq.so.5: undefined reference to ERR_reason_error_string@OPENSSL_1.0.0' usr/lib/libpq.so.5: undefined reference to SSL_CTX_ctrl@OPENSSL_1.0.0' usr/lib/libpq.so.5: undefined reference toSSL_pending@OPENSSL_1.0.0' usr/lib/libpq.so.5: undefined reference to SSL_use_PrivateKey@OPENSSL_1.0.0' usr/lib/libvtkIO.so.5.8.0: undefined reference to TIFFSetWarningHandler@LIBTIFF_4.0' usr/lib/libpq.so.5: undefined reference to ENGINE_finish@OPENSSL_1.0.0' usr/lib/libvtkIO.so.5.8.0: undefined reference toTIFFSetErrorHandler@LIBTIFF_4.0' usr/lib/libvtkIO.so.5.8.0: undefined reference to _TIFFmalloc@LIBTIFF_4.0' usr/lib/libpq.so.5: undefined reference to SSL_library_init@OPENSSL_1.0.0' usr/lib/libvtkIO.so.5.8.0: undefined reference to TIFFSetDirectory@LIBTIFF_4.0' usr/lib/libvtkIO.so.5.8.0: undefined reference toTIFFReadScanline@LIBTIFF_4.0' usr/lib/libpq.so.5: undefined reference to SSL_shutdown@OPENSSL_1.0.0' usr/lib/libvtkIO.so.5.8.0: undefined reference toTIFFNumberOfTiles@LIBTIFF_4.0' collect2: error: ld returned 1 exit status make[2]: * [pcl_visualizer] Error 1 make1: * [CMakeFiles/pcl_visualizer.dir/all] Error 2 make: *** [all] Error 2

The CmakeList file is define as follow:

cmake_minimum_required (VERSION 2.6 FATAL_ERROR)

project      (pcl-visualizer)
find_package (Qt4 REQUIRED)
find_package (VTK REQUIRED)
find_package (PCL 1.7.1 REQUIRED)

include_directories (${PCL_INCLUDE_DIRS})
link_directories    (${PCL_LIBRARY_DIRS})
add_definitions     (${PCL_DEFINITIONS})

set  (project_SOURCES main.cpp pclviewer.cpp)
set  (project_HEADERS pclviewer.h)
set  (project_FORMS   pclviewer.ui)
set  (VTK_LIBRARIES   vtkRendering vtkGraphics vtkHybrid QVTK)

QT4_WRAP_CPP (project_HEADERS_MOC   ${project_HEADERS})
QT4_WRAP_UI  (project_FORMS_HEADERS ${project_FORMS})

INCLUDE         (${QT_USE_FILE})
ADD_DEFINITIONS (${QT_DEFINITIONS})

ADD_EXECUTABLE  (pcl_visualizer ${project_SOURCES}
                                ${project_FORMS_HEADERS}
                                ${project_HEADERS_MOC})

TARGET_LINK_LIBRARIES (pcl_visualizer ${QT_LIBRARIES} ${PCL_LIBRARIES} ${VTK_LIBRARIES})

Is there anything missing in the CMakeList file?


Solution

  • The PostgreSQL library you are linking to is missing openssl, you can check it with

    ldd /usr/lib/libpq.so.5
    

    it should report something like

    libssl.so.1.0.0 => not found
    

    The same with vtk, but it doesn't find a valid TIFF library.

    First, check that you have both openssl and tiff libraries installed, if linking still fails, check if versions are correct.

    Second, if all libraries are installed, check if are from the correct architecture (all 32-bit or all 64-bit).

    Third, manually force your project to load libraries flags (both from command line CMAKE_MODULE_LINKER_FLAGS / CMAKE_SHARED_LINKER_FLAGS or in the target_link_libraries directive).