Saturday, October 29, 2022

[SOLVED] Linker command failed. CMAKE_INSTALL_RPATH not working

Issue

Trying to build a simple application with EASTL lib and having an error while building cmake --build . I don't know where is my mistake. Getting error:

/usr/bin/ld: warning: libc++.so.1, needed by /home/user_name/.conan/data/eastl/package/lib/libEASTL.so, not found (try using -rpath or -rpath-link)

/usr/bin/ld: warning: libc++abi.so.1, needed by /home/user_name/.conan/data/eastl/package/lib/libEASTL.so, not found (try using -rpath or -rpath-link)

/usr/bin/ld: /home/user_name/.conan/data/eastl/package/lib/libEASTL.so: undefined reference to `std::__1::mutex::lock()'

clang: error: linker command failed with exit code 1 (use -v to see invocation)

gmake[2]: *** [CMakeFiles/md5.dir/build.make:97: bin/md5] Error 1

gmake[1]: *** [CMakeFiles/Makefile2:83: CMakeFiles/md5.dir/all] Error 2

gmake: *** [Makefile:91: all] Error 2

My CMakeLists.txt:

cmake_minimum_required(VERSION 3.21)

project(MD5Encrypter)

add_definitions("-std=c++17")

include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake)

set(CMAKE_BUILD_RPATH_USE_ORIGIN ON)
set(CMAKE_BUILD_WITH_INSTALL_RPATH ON)
set(CMAKE_SKIP_BUILD_RPATH OFF)
set(CMAKE_INSTALL_RPATH_USE_LINK_PATH ON)
set(CMAKE_INSTALL_RPATH "$ORIGIN/../.lib")

conan_basic_setup()

add_executable(md5 main.cpp)

target_link_libraries(md5 ${CONAN_LIBS})

Have libEASTL.so in {project_dir}/.lib


Solution

Find the solution. The problem was is missing package libc++-dev So, the solution is to install it: sudo apt install libc++-dev



Answered By - Erik Johnson
Answer Checked By - Cary Denson (WPSolving Admin)