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

01-basic/E-installing: cannot open shared object file #82

Open
syheliel opened this issue Jul 5, 2022 · 1 comment
Open

01-basic/E-installing: cannot open shared object file #82

syheliel opened this issue Jul 5, 2022 · 1 comment

Comments

@syheliel
Copy link

syheliel commented Jul 5, 2022

here is my command and output:

❯ cmake -B ./build/ -DCMAKE_EXPORT_COMPILE_COMMANDS=on && sudo cmake --build build --target install
-- The C compiler identification is GNU 11.2.0
-- The CXX compiler identification is GNU 11.2.0
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: /usr/bin/cc - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: /usr/bin/c++ - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Configuring done
-- Generating done
-- Build files have been written to: /home/xxx/git/cmake-examples/01-basic/E-installing/build
[ 25%] Building CXX object CMakeFiles/cmake_examples_inst.dir/src/Hello.cpp.o
[ 50%] Linking CXX shared library libcmake_examples_inst.so
[ 50%] Built target cmake_examples_inst
[ 75%] Building CXX object CMakeFiles/cmake_examples_inst_bin.dir/src/main.cpp.o
[100%] Linking CXX executable cmake_examples_inst_bin
[100%] Built target cmake_examples_inst_bin
Install the project...
-- Install configuration: ""
-- Installing: /usr/local/bin/cmake_examples_inst_bin
-- Set runtime path of "/usr/local/bin/cmake_examples_inst_bin" to ""
-- Installing: /usr/local/lib/libcmake_examples_inst.so
-- Up-to-date: /usr/local/include
-- Up-to-date: /usr/local/include/installing
-- Up-to-date: /usr/local/include/installing/Hello.h
-- Up-to-date: /usr/local/etc/cmake-examples.conf

reopen the terminal and then run cmake_examples_inst_bin gives following error:

cmake_examples_inst_bin: error while loading shared libraries: libcmake_examples_inst.so: cannot open shared object file: No such file or directory

output of ldd:

ldd $(which cmake_examples_inst_bin)
	linux-vdso.so.1 (0x00007ffe6751d000)
	libcmake_examples_inst.so => not found
	libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007f1713bc0000)
	/lib64/ld-linux-x86-64.so.2 (0x00007f1713e00000)
@KaivinC
Copy link

KaivinC commented Jun 4, 2023

set_target_properties(cmake_examples_inst_bin PROPERTIES
INSTALL_RPATH ${CMAKE_INSTALL_PREFIX}/lib
)

You can add the command above before running the 'install(cmake_examples_inst_bin)' to tell the system to look for shared libraries in "${CMAKE_INSTALL_PREFIX}/lib" when running the cmake_examples_inst_bin executable

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

2 participants