Why the Symlink Approach is Not Ideal:
In Gentoo, /usr/lib is conventionally used for 32-bit libraries, while /usr/lib64 is for 64-bit libraries on amd64 systems. By manually creating a symlink from /usr/lib64/libssh2.so (64-bit) to /usr/lib/libssh2.so, you might resolve the immediate issue, but it can cause confusion and potential conflicts with other packages that rely on the correct 32/64-bit separation. This approach is generally discouraged because it disrupts the system's standard library organization.
Finding the Real Issue:
The correct approach in a situation like this is to investigate why the build process was looking in /usr/lib for a 64-bit library. It could be due to an incorrect configuration or environment setting. For instance, there might be an issue with the LDFLAGS or PKG_CONFIG_PATH environment variables pointing to the wrong library path.
CMake and libssh2 Dependency:
As mentioned, CMake does not directly depend on libssh2. If a component of CMake was failing due to libssh2, it might be an indirect dependency or a specific feature of CMake requiring libssh2. Understanding the exact dependency chain can help address the root cause without resorting to manual workarounds like symlinks.
Advice on Using emerge:
Using sudo emerge can indeed cause issues due to environmental variables from the user's environment affecting the build process. It's recommended to become the root user with a clean environment (sudo -i or su -l) before running emerge commands. This ensures a stable and clean build environment.
Next Steps:
To proceed, you should remove the manually created symlink:
sudo rm /usr/lib/libssh2.so
Then, investigate the build process of CMake or the failing component to understand why it was looking for libssh2 in /usr/lib. The build.log file should contain detailed information about the failure and can guide you to the underlying issue.
Ensure your build environment is clean and your environment variables are correctly set to reference the appropriate library paths for a 64-bit build.
By addressing the root cause of the library path issue and ensuring a proper build environment, you can achieve a more stable and maintainable solution. This approach aligns with Gentoo's best practices and reduces the likelihood of encountering similar issues in the future.
Original code from compilation cmake with standard emerge. It shows that somehow cmake is depended by libssh2. And I am able to recreate that error, emerging again libssh2 with standard settings for gentoo. and then trying emerge cmake.
Code: Select all
[ebuild R ] net-libs/libssh2-1.11.0-r2::gentoo USE="zlib -gcrypt -mbedtls -test" ABI_X86="32* (64) (-x32)" 0 KiB
Code: Select all
[ebuild R ] dev-util/cmake-3.27.7::gentoo USE="ncurses -dap -doc -emacs -gui -qt6 -test -verify-sig" 0 KiB
This is error what I faced.
Code: Select all
[ 90%] Building CXX object Source/CMakeFiles/CTestLib.dir/CTest/cmCTestEmptyBinaryDirectoryCommand.cxx.o
cd /var/tmp/portage/dev-util/cmake-3.27.7/work/cmake-3.27.7_build/Source && /usr/bin/x86_64-pc-linux-gnu-g++ -I/var/tmp/portage/dev-util/cmake-3.27.7/work/cmake-3.27.7_build/Utilities -I/var/tmp/portage/dev-util/cmake-3.27.7/work/cmake-3.27.7/Source/CTest -I/var/tmp/portage/dev-util/cmake-3.27.7/work/cmake-3.27.7_build/Source -I/var/tmp/portage/dev-util/cmake-3.27.7/work/cmake-3.27.7/Source -I/var/tmp/portage/dev-util/cmake-3.27.7/work/cmake-3.27.7/Source/LexerParser -isystem /var/tmp/portage/dev-util/cmake-3.27.7/work/cmake-3.27.7/Utilities/std -isystem /var/tmp/portage/dev-util/cmake-3.27.7/work/cmake-3.27.7/Utilities -isystem /usr/include/jsoncpp -pipe -march=native -std=c++17 -Wno-deprecated-declarations -MD -MT Source/CMakeFiles/CTestLib.dir/CTest/cmCTestEmptyBinaryDirectoryCommand.cxx.o -MF CMakeFiles/CTestLib.dir/CTest/cmCTestEmptyBinaryDirectoryCommand.cxx.o.d -o CMakeFiles/CTestLib.dir/CTest/cmCTestEmptyBinaryDirectoryCommand.cxx.o -c /var/tmp/portage/dev-util/cmake-3.27.7/work/cmake-3.27.7/Source/CTest/cmCTestEmptyBinaryDirectoryCommand.cxx
/usr/lib/gcc/x86_64-pc-linux-gnu/13/../../../../x86_64-pc-linux-gnu/bin/ld: /usr/lib/libssh2.so: error adding symbols: file in wrong format
collect2: error: ld returned 1 exit status
make[2]: *** [Source/CursesDialog/CMakeFiles/ccmake.dir/build.make:321: bin/ccmake] Error 1
make[2]: Leaving directory '/var/tmp/portage/dev-util/cmake-3.27.7/work/cmake-3.27.7_build'
make[1]: *** [CMakeFiles/Makefile2:559: Source/CursesDialog/CMakeFiles/ccmake.dir/all] Error 2
Code: Select all
[ 86%] Building CXX object Source/CMakeFiles/CTestLib.dir/CTest/cmCTestCoverageCommand.cxx.o
cd /var/tmp/portage/dev-util/cmake-3.27.7/work/cmake-3.27.7_build/Source && /usr/bin/x86_64-pc-linux-gnu-g++ -I/var/tmp/portage/dev-util/cmake-3.27.7/work/cmake-3.27.7_build/Utilities -I/var/tmp/portage/dev-util/cmake-3.27.7/work/cmake-3.27.7/Source/CTest -I/var/tmp/portage/dev-util/cmake-3.27.7/work/cmake-3.27.7_build/Source -I/var/tmp/portage/dev-util/cmake-3.27.7/work/cmake-3.27.7/Source -I/var/tmp/portage/dev-util/cmake-3.27.7/work/cmake-3.27.7/Source/LexerParser -isystem /var/tmp/portage/dev-util/cmake-3.27.7/work/cmake-3.27.7/Utilities/std -isystem /var/tmp/portage/dev-util/cmake-3.27.7/work/cmake-3.27.7/Utilities -isystem /usr/include/jsoncpp -pipe -march=native -std=c++17 -Wno-deprecated-declarations -MD -MT Source/CMakeFiles/CTestLib.dir/CTest/cmCTestCoverageCommand.cxx.o -MF CMakeFiles/CTestLib.dir/CTest/cmCTestCoverageCommand.cxx.o.d -o CMakeFiles/CTestLib.dir/CTest/cmCTestCoverageCommand.cxx.o -c /var/tmp/portage/dev-util/cmake-3.27.7/work/cmake-3.27.7/Source/CTest/cmCTestCoverageCommand.cxx
/usr/lib/gcc/x86_64-pc-linux-gnu/13/../../../../x86_64-pc-linux-gnu/bin/ld: /usr/lib/libssh2.so: error adding symbols: file in wrong format
collect2: error: ld returned 1 exit status
make[2]: *** [Source/CMakeFiles/cmake.dir/build.make:126: bin/cmake] Error 1
make[2]: Leaving directory '/var/tmp/portage/dev-util/cmake-3.27.7/work/cmake-3.27.7_build'
make[1]: *** [CMakeFiles/Makefile2:473: Source/CMakeFiles/cmake.dir/all] Error 2
make[1]: *** Waiting for unfinished jobs....
exact this line
/usr/lib/gcc/x86_64-pc-linux-gnu/13/../../../../x86_64-pc-linux-gnu/bin/ld: /usr/lib/libssh2.so: error adding symbols: file in wrong format
I know that normally I do not want mess wit libs but that case was making me crazy from few years, last time I did update system by skipping cmake, and installing it manually from /var/tmp/portage/dev-util/cmake-... using ./configure ; make ; make install ; But system still see old version for updating. This time I found solution to emerge everything and solve problem to cmake.