Hello I am new to linux and cmake.
I want to run a binary file linked only as a static library on another linux. But while running the binary, I faced the following error.
// new centos-6 vmware
./CMakeForLinux: /usr/lib64/libstdc++.so.6: version `GLIBCXX_3.4.17' not found (required by ./CMakeForLinux)
./CMakeForLinux: /usr/lib64/libstdc++.so.6: version `GLIBCXX_3.4.18' not found (required by ./CMakeForLinux)
./CMakeForLinux: /usr/lib64/libstdc++.so.6: version `GLIBCXX_3.4.15' not found (required by ./CMakeForLinux)
./CMakeForLinux: /usr/lib64/libstdc++.so.6: version `GLIBCXX_3.4.14' not found (required by ./CMakeForLinux)
./CMakeForLinux: /usr/lib64/libstdc++.so.6: version `CXXABI_1.3.5' not found (required by ./CMakeForLinux)
./CMakeForLinux: /usr/lib64/libstdc++.so.6: version `GLIBCXX_3.4.19' not found (required by ./CMakeForLinux)
./CMakeForLinux: /lib64/libc.so.6: version `GLIBC_2.17' not found (required by ./CMakeForLinux)
./CMakeForLinux: /lib64/libc.so.6: version `GLIBC_2.14' not found (required by ./CMakeForLinux)
./CMakeForLinux: /lib64/libc.so.6: version `GLIBC_2.16' not found (required by ./CMakeForLinux)
The ".so" file is known as a dynamic library.
So I checked the environment of the machine where I built the binary.
// built vmware-machine (centos-7)
[root@localhost ~]$ sudo find / -name "libstdc++.so.6"
/usr/lib64/libstdc++.so.6
[root@localhost ~]$ sudo find / -name "libstdc++.a"
/usr/lib/gcc/x86_64-redhat-linux/4.8.2/32/libstdc++.a
/opt/rh/devtoolset-8/root/usr/lib/gcc/x86_64-redhat-linux/8/libstdc++.a
/opt/rh/devtoolset-8/root/usr/lib/gcc/x86_64-redhat-linux/8/32/libstdc++.a
/opt/rh/devtoolset-9/root/usr/lib/gcc/x86_64-redhat-linux/9/libstdc++.a
/opt/rh/devtoolset-9/root/usr/lib/gcc/x86_64-redhat-linux/9/32/libstdc++.a
[root@localhost ~]# ll /usr/lib64/libstdc++.so.6
lrwxrwxrwx. 1 root root 19 Aug 21 20:15 /usr/lib64/libstdc++.so.6 -> libstdc++.so.6.0.19
[root@localhost ~]# strings /usr/lib64/libstdc++.so.6.0.19 | grep GLIBCXX
GLIBCXX_3.4
GLIBCXX_3.4.1
GLIBCXX_3.4.2
GLIBCXX_3.4.3
GLIBCXX_3.4.4
GLIBCXX_3.4.5
GLIBCXX_3.4.6
GLIBCXX_3.4.7
GLIBCXX_3.4.8
GLIBCXX_3.4.9
GLIBCXX_3.4.10
GLIBCXX_3.4.11
GLIBCXX_3.4.12
GLIBCXX_3.4.13
GLIBCXX_3.4.14
GLIBCXX_3.4.15
GLIBCXX_3.4.16
GLIBCXX_3.4.17
GLIBCXX_3.4.18
GLIBCXX_3.4.19
GLIBCXX_DEBUG_MESSAGE_LENGTH
My CMakeList.txt
set(CMAKE_CXX_STANDARD 17)
I've tried the following
set(CMAKE_EXE_LINKER_FLAGS "-static-libgcc -static-libstdc++ -static")
set(CMAKE_SHARED_LINKER_FLAGS "-static-libgcc -static-libstdc++ -static")
// build error
FAILED: CMakeForLinux/CMakeForLinux
: && /opt/rh/devtoolset-9/root/usr/bin/c++ -g -static-libgcc -static-libstdc++ -static CMakeForLinux/CMakeFiles/CMakeForLinux.dir/CMakeForLinux.cpp.o CMakeForLinux/CMakeFiles/CMakeForLinux.dir/__/ClientUpdater/DataUtil.cpp.o CMakeForLinux/CMakeFiles/CMakeForLinux.dir/__/ClientUpdater/HttpUtil.cpp.o CMakeForLinux/CMakeFiles/CMakeForLinux.dir/__/ClientUpdater/LicenseConverter.cpp.o CMakeForLinux/CMakeFiles/CMakeForLinux.dir/__/ClientUpdater/ProductSubSetGuider.cpp.o CMakeForLinux/CMakeFiles/CMakeForLinux.dir/__/ClientUpdater/ClientPathGuider.cpp.o CMakeForLinux/CMakeFiles/CMakeForLinux.dir/__/ClientUpdater/FileSetUpdater.cpp.o CMakeForLinux/CMakeFiles/CMakeForLinux.dir/__/ClientUpdater/DeSerializer.cpp.o CMakeForLinux/CMakeFiles/CMakeForLinux.dir/__/ClientUpdater/MemoryBuffer.cpp.o CMakeForLinux/CMakeFiles/CMakeForLinux.dir/__/ClientUpdater/DecryptLea.cpp.o CMakeForLinux/CMakeFiles/CMakeForLinux.dir/__/ClientUpdater/SetupFileUpdater.cpp.o CMakeForLinux/CMakeFiles/CMakeForLinux.dir/__/ClientUpdater/Updater.cpp.o -o CMakeForLinux/CMakeForLinux /usr/local/lib64/libssl.a /usr/local/lib64/libcrypto.a -lpthread -ldl /home/junhyuk/.vs/jsoncpp/jsoncpp-1.9.5/build/debug/lib/libjsoncpp.a ../../../linux_so/1.2-1/lib/liblea.a && :
/opt/rh/devtoolset-9/root/usr/libexec/gcc/x86_64-redhat-linux/9/ld: cannot find -lpthread
/opt/rh/devtoolset-9/root/usr/libexec/gcc/x86_64-redhat-linux/9/ld: cannot find -ldl
/opt/rh/devtoolset-9/root/usr/libexec/gcc/x86_64-redhat-linux/9/ld: cannot find -lm
/opt/rh/devtoolset-9/root/usr/libexec/gcc/x86_64-redhat-linux/9/ld: cannot find -lc
But I got an error creating cmake. (Using visualstudio 2019, CMakeProject Template)
I want to make a binary linked with libstdc++.a as a static library in centos7 vmware that built an existing binary.