I have a problem with linking QGIS libraries with a newer version ,
i m using CENTOS 7 , there is an old QGIS version ( QGIS 2.14 )in /usr/lib64 which contains libqgis*.so and there is another newest QGIS version ( 3.18 ) installed in /sir/LIB_QGIS/QGIS3 , i created a cmake program to force using the newer version but the problem is that my program still link with the oldest one ( in usr/lib64 )
here is my CMakeLists.txt
cmake_minimum_required(VERSION 3.10)
project(MyQGISProject)
# Add the custom path to the CMAKE_PREFIX_PATH
set(CMAKE_PREFIX_PATH "/sitr/LIB_QGIS/QGIS3/usr/local" ${CMAKE_PREFIX_PATH})
set(CMAKE_LIBRARY_PATH "/sitr/LIB_QGIS/QGIS3/usr/local/lib" ${CMAKE_LIBRARY_PATH})
set(CMAKE_INCLUDE_PATH "/sitr/LIB_QGIS/QGIS3/usr/local/include" ${CMAKE_INCLUDE_PATH})
# Optionally set environment variables for the runtime linker
set(ENV{LD_LIBRARY_PATH} "/sitr/LIB_QGIS/QGIS3/lib:$ENV{LD_LIBRARY_PATH}")
# Find the QGIS libraries
find_library(QGIS_CORE_LIBRARY qgis_core PATHS /sitr/LIB_QGIS/QGIS3/usr/local/lib)
find_library(QGIS_GUI_LIBRARY qgis_gui PATHS /sitr/LIB_QGIS/QGIS3/usr/local/lib)
find_library(QGIS_ANALYSIS_LIBRARY qgis_analysis PATHS /sitr/LIB_QGIS/QGIS3/usr/local/lib)
find_library(QGIS_NATIVE_LIBRARY qgis_native PATHS /sitr/LIB_QGIS/QGIS3/usr/local/lib)
# Include directories
include_directories("/sitr/LIB_QGIS/QGIS3/include")
# Define the executable
add_executable(${PROJECT_NAME} main.cpp)
# Link the QGIS libraries to the executable
target_link_libraries(${PROJECT_NAME}
${QGIS_CORE_LIBRARY}
${QGIS_GUI_LIBRARY}
${QGIS_ANALYSIS_LIBRARY}
# ${QGIS_NATIVE_LIBRARY}
)
# Debugging: Print the paths to ensure correct linking
message(STATUS "QGIS core library: ${QGIS_CORE_LIBRARY}")
message(STATUS "QGIS GUI library: ${QGIS_GUI_LIBRARY}")
message(STATUS "QGIS analysis library: ${QGIS_NATIVE_LIBRARY}")
message(STATUS "LD_LIBRARY_PATH: $ENV{LD_LIBRARY_PATH}")
here is the CmakeOutput :
the only correct library .so is the QGIS_ANALYSIS_LIBRARY because he could not find the file in /usr/lib64 so he tooked the one i wanted in /sitr/LIB_QGIS/QGIS3/usr/local/lib , but for the others one ( qgis_core , qgis_gui ) , he took the oldest version located in /usr/lib64
How to force my CMakeLists to link with the newest one located in /sitr/LIB_QGIS/QGIS3/usr/local/lib and ignore the ones in /usr/lib64 even if they still exist ?? Big thanks 🙂