How to build and link for specific GLIBC version - linux

My ubuntu build environment by default uses g++ 9.4.0 with this ldd version:
ldd (Ubuntu GLIBC 2.31-0ubuntu9.7) 2.31
My run environment is a hadoop environment that must be using a much older GLIBC because it gives me errors like this when I try to run myApp there:
./myApp: /lib64/libm.so.6: version `GLIBC_2.29' not found (required by ./myApp)
./myApp: /usr/lib64/libstdc++.so.6: version `GLIBCXX_3.4.20' not found (required by ./myApp)
./myApp: /usr/lib64/libstdc++.so.6: version `CXXABI_1.3.8' not found (required by ./myApp)
./myApp: /usr/lib64/libstdc++.so.6: version `GLIBCXX_3.4.21' not found (required by ./myApp)
I'm looking to resolve these errors in whichever way is easiest, but since I'm unsure of how to upgrade the hadoop environment, I'm starting with seeing if I can instead build using a lower GLIBC that will be available on the run environment. I'm struggling to understand how to accomplish this. To start, I've tried to install g++4.8 on the build environment as follows:
sudo apt-get install gcc-4.8 g++-4.8 build-essential
sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-4.8 10
sudo update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-4.8 10
sudo update-alternatives --install /usr/bin/cc cc /usr/bin/gcc 30
sudo update-alternatives --list cc
sudo update-alternatives --set cc /usr/bin/gcc
sudo update-alternatives --install /usr/bin/c++ c++ /usr/bin/g++ 30
sudo update-alternatives --list c++
sudo update-alternatives --set c++ /usr/bin/g++
g++ --version
gcc --version
ldd --version
I was able to get this to install using bionic repos, but the ldd output is still GLIBC 2.31:
Setting up gcc-4.8-base:amd64 (4.8.5-4ubuntu8) ...
Setting up cpp-4.8 (4.8.5-4ubuntu8) ...
Setting up libasan0:amd64 (4.8.5-4ubuntu8) ...
Setting up gcc (4:9.3.0-1ubuntu2) ...
Setting up g++ (4:9.3.0-1ubuntu2) ...
update-alternatives: using /usr/bin/g++ to provide /usr/bin/c++ (c++) in auto mode
Setting up build-essential (12.8ubuntu1.1) ...
Setting up libgcc-4.8-dev:amd64 (4.8.5-4ubuntu8) ...
Setting up gcc-4.8 (4.8.5-4ubuntu8) ...
Setting up libstdc++-4.8-dev:amd64 (4.8.5-4ubuntu8) ...
Setting up g++-4.8 (4.8.5-4ubuntu8) ...
Processing triggers for man-db (2.9.1-1) ...
Processing triggers for libc-bin (2.31-0ubuntu9.7) ...
update-alternatives: using /usr/bin/gcc-4.8 to provide /usr/bin/gcc (gcc) in auto mode
update-alternatives: using /usr/bin/g++-4.8 to provide /usr/bin/g++ (g++) in auto mode
update-alternatives: warning: forcing reinstallation of alternative /usr/bin/gcc because link group cc is broken
/usr/bin/gcc
update-alternatives: warning: forcing reinstallation of alternative /usr/bin/g++ because link group c++ is broken
/usr/bin/g++
g++ (Ubuntu 4.8.5-4ubuntu8) 4.8.5
Copyright (C) 2015 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
gcc (Ubuntu 4.8.5-4ubuntu8) 4.8.5
Copyright (C) 2015 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
ldd (Ubuntu GLIBC 2.31-0ubuntu9.7) 2.31
Copyright (C) 2020 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
When I run the resulting myApp on the run environment again, I get the same errors I noted above.
Is there a step that I'm missing to either force a specific GLIBC version or to update my build environment to use a g++ that defaults to a lower GLIBC version? I haven't found a way to use g++ 9.4.0 with say GLIBC_2.15 but can someone share with me tips on how that could be done?

Related

Error when bootstrapping CMake:Log of errors

To install charmm program I have to install CMake, however, it doesn't install CMake.
[sohyeon#theochem11 cmake-3.15.3]$ ./bootstrap
---------------------------------------------
CMake 3.15.3, Copyright 2000-2019 Kitware, Inc. and Contributors
Found GNU toolchain
C compiler on this system is: gcc
---------------------------------------------
Error when bootstrapping CMake:
Cannot find a C++ compiler that supports both C++11 and the specified C++ flags.
Please specify one using environment variable CXX.
The C++ flags are "".
They can be changed using the environment variable CXXFLAGS.
See cmake_bootstrap.log for compilers attempted.
---------------------------------------------
Log of errors: /export/home/sohyeon/cmake-3.15.3/Bootstrap.cmk/cmake_bootstrap.log
so I tried to that script
[sohyeon#theochem11 cmake-3.15.3]$ env CC=cc CXX=CC ./bootstrap
But it still occurred same error.
I searched other ways in google. I found this two ways.
$ yum -y install gcc-c++
You need to be root to perform this command.
$ yum install gcc-c++.x86_64
You need to be root to perform this command.
But it is not solve my problem.
(And I saw cmake_bootstrap.log but I don't know what is wrong.)
(Edit)
Thank you all!
OS version : Linux theochem11.hpc.org 2.6.32-279.14.1.el6.x86_64 #1 SMP Tue Nov 6 23:43:09 UTC 2012 x86_64 x86_64 x86_64 GNU/Linux
[sohyeon#theochem11 cmake-3.15.3]$ gcc --version
gcc (GCC) 4.4.6 20120305 (Red Hat 4.4.6-4)
Copyright (C) 2010 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
[sohyeon#theochem11 cmake-3.15.3]$ g++ --version
g++ (GCC) 4.4.6 20120305 (Red Hat 4.4.6-4)
Copyright (C) 2010 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
cmake-3.15.3 can do bootstrap with g++ versions 6.3 .. 9.2 . ... Earlier g++ versions like 4.9 or 5.3 are failing.
RHEL 6, install gcc-c++-7.3 :
# 1. Install a package with repository for your system:
# On CentOS, install package centos-release-scl available in CentOS repository:
$ sudo yum install centos-release-scl
# On RHEL, enable RHSCL repository for you system:
$ sudo yum-config-manager --enable rhel-server-rhscl-7-rpms
# 2. Install the collection:
$ sudo yum install devtoolset-7
# 3. Start using software collections:
$ scl enable devtoolset-7 bash
https://www.softwarecollections.org/en/scls/rhscl/devtoolset-7/
Five packages only are installed, with 'yum install devtoolset-7-gcc-c++' :
devtoolset-7-gcc-c++-7.3.1-5.15.el6.x86_64
devtoolset-7-binutils-2.28-11.el6.x86_64
devtoolset-7-libstdc++-devel-7.3.1-5.15.el6.x86_64
devtoolset-7-runtime-7.1-4.el6.x86_64
devtoolset-7-gcc-7.3.1-5.15.el6.x86_64
Packages http://mirror.centos.org/centos/7/sclo/x86_64/rh/devtoolset-7/
Cmake :
cd cmake-3.15.3/
scl enable devtoolset-7 bash // g++ is set to "7.3"
./bootstrap
Note : The command scl enable devtoolset-7 bash is valid for the current terminal session only.
P.S. : cmake3 is available from the EPEL repo https://fedoraproject.org/wiki/EPEL → sudo yum install cmake3 . You get cmake3-3.6.1-3.el6.x86_64 . Provides /usr/bin/cmake3
Epel packages https://dl.fedoraproject.org/pub/epel/6/x86_64/Packages/
Ref. comment
Is there any other way than using yum?
The rpm command can be used to install downloaded packages : Root password is required. Examples ...
rpm -Uvh cmake3-3.6.1-3.el6.x86_64
rpm -Uvh <package>.rpm <package>.rpm <package>.rpm <package>.rpm <package>.rpm
I met the same problems,you can solve it by downloading the latest version

Cannot use CONFIG_CC_STACKPROTECTOR_STRONG: -fstack-protector-strong not supported by compiler

I'm running Ubuntu 16.10 in my laptop;
I have recently downloaded Linux kernel from git, but when I am trying to compile it with a make command from the terminal.
It is giving me
"error:Cannot use CONFIG_CC_STACKPROTECTOR_STRONG:
-fstack-protector-strong not supported by compiler"
What should I do to resolve this problem?
See this thread and this answer: this error could be the result of multiple gcc versions alternatives.
See "What exactly does update-alternatives do?"
Clear them out:
$ sudo update-alternatives --remove-all gcc
$ sudo update-alternatives --remove-all g++
Then re-install them, and make sure your gcc and g++ reference the same version.
sudo update-alternatives --config gcc
sudo update-alternatives --config g++
Note (March 2017): doug65536 mentions in the comments another case:
I found a solution to the issue with my nvidia driver package.
I had installed a custom build of binutils for a gdb patch.
Forcing it to reinstall binutils resolved the issue. It makes no sense, but it worked.

How to change the GCC version

I just install a kali-linux, and trying to play with it.
I did use ubuntu before. That cause some problems with different gcc version when I am trying to use some code what I build in my old Ubuntu.
I check the gcc -v; the kali give me
gcc version 6.1.1 20160802(Debian 6.1.1-11)
and ubuntu give me
gcc version 5.4.0 20160609 (ubuntu 5.4.0-6ubuntu1~16.04.2)
I am not sure if my code doesn't compile because of this or not. But just want to check.
how can I remove Debian's gcc and switch to ubuntu one?
May be i'm not much familiar with debian. But with Ubuntu, i've followed this and changed the gcc version. May be this will help.
Change default gcc version
You can use this command to install gcc versions.
sudo apt-get install gcc-4.3 gcc-4.4
Once installed, you have to update the alternatives with the variant gcc versions. Using
sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-4.3 10
You can choose which version of gcc, you can use by this command.
sudo update-alternatives --config gcc

Why can't clang++ on Ubuntu 14.04 find <iostream>

I am compiling this program:
#include <iostream>
int main()
{
}
This command
g++ -c hello_world.cpp
works.
This command
clang++ -c hello_world.cpp
gives this error:
hello_world.cpp:1:10: fatal error: 'iostream' file not found
#include <iostream>
^
1 error generated.
Doing:
clang++ -c hello_world.cpp -v
gives:
Ubuntu clang version 3.4-1ubuntu3 (tags/RELEASE_34/final) (based on LLVM 3.4)
Target: x86_64-pc-linux-gnu
Thread model: posix
Found candidate GCC installation: /usr/bin/../lib/gcc/i686-linux-gnu/4.8
Found candidate GCC installation: /usr/bin/../lib/gcc/i686-linux-gnu/4.8.4
Found candidate GCC installation: /usr/bin/../lib/gcc/i686-linux-gnu/4.9
Found candidate GCC installation: /usr/bin/../lib/gcc/i686-linux-gnu/4.9.1
Found candidate GCC installation: /usr/bin/../lib/gcc/x86_64-linux-gnu/4.8
Found candidate GCC installation: /usr/bin/../lib/gcc/x86_64-linux-gnu/4.8.4
Found candidate GCC installation: /usr/bin/../lib/gcc/x86_64-linux-gnu/4.9
Found candidate GCC installation: /usr/bin/../lib/gcc/x86_64-linux-gnu/4.9.1
Found candidate GCC installation: /usr/lib/gcc/i686-linux-gnu/4.8
Found candidate GCC installation: /usr/lib/gcc/i686-linux-gnu/4.8.4
Found candidate GCC installation: /usr/lib/gcc/i686-linux-gnu/4.9
Found candidate GCC installation: /usr/lib/gcc/i686-linux-gnu/4.9.1
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/4.8
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/4.8.4
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/4.9
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/4.9.1
Selected GCC installation: /usr/bin/../lib/gcc/x86_64-linux-gnu/4.9
"/usr/bin/clang" -cc1 -triple x86_64-pc-linux-gnu -emit-obj -mrelax-all -disable-free -disable-llvm-verifier -main-file-name hello_world.cpp -mrelocation-model static -mdisable-fp-elim -fmath-errno -masm-verbose -mconstructor-aliases -munwind-tables -fuse-init-array -target-cpu x86-64 -target-linker-version 2.24 -v -coverage-file /home/user/code/cpp/StackOverflow_questions/hello_world.o -resource-dir /usr/bin/../lib/clang/3.4 -internal-isystem /usr/bin/../lib/gcc/x86_64-linux-gnu/4.9/../../../../include/c++ -internal-isystem /usr/bin/../lib/gcc/x86_64-linux-gnu/4.9/../../../../include/c++/x86_64-linux-gnu -internal-isystem /usr/bin/../lib/gcc/x86_64-linux-gnu/4.9/../../../../include/c++/backward -internal-isystem /usr/local/include -internal-isystem /usr/bin/../lib/clang/3.4/include -internal-externc-isystem /usr/bin/../lib/gcc/x86_64-linux-gnu/4.9/include -internal-externc-isystem /usr/include/x86_64-linux-gnu -internal-externc-isystem /include -internal-externc-isystem /usr/include -fdeprecated-macro -fdebug-compilation-dir /home/user/code/cpp/StackOverflow_questions -ferror-limit 19 -fmessage-length 202 -mstackrealign -fobjc-runtime=gcc -fcxx-exceptions -fexceptions -fdiagnostics-show-option -vectorize-slp -o hello_world.o -x c++ hello_world.cpp
clang -cc1 version 3.4 based upon LLVM 3.4 default target x86_64-pc-linux-gnu
ignoring nonexistent directory "/usr/bin/../lib/gcc/x86_64-linux-gnu/4.9/../../../../include/c++/x86_64-linux-gnu"
ignoring nonexistent directory "/usr/bin/../lib/gcc/x86_64-linux-gnu/4.9/../../../../include/c++/backward"
ignoring nonexistent directory "/include"
#include "..." search starts here:
#include <...> search starts here:
/usr/bin/../lib/gcc/x86_64-linux-gnu/4.9/../../../../include/c++
/usr/local/include
/usr/bin/../lib/clang/3.4/include
/usr/bin/../lib/gcc/x86_64-linux-gnu/4.9/include
/usr/include/x86_64-linux-gnu
/usr/include
End of search list.
hello_world.cpp:1:10: fatal error: 'iostream' file not found
#include <iostream>
^
1 error generated.
clang++ is talking about using gcc 4.9 stuff, but if I do:
g++ --version
it outputs:
g++ --version
g++ (Ubuntu 4.8.4-2ubuntu1~14.04) 4.8.4
Copyright (C) 2013 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE
This is where iostream is located on my machine:
/usr/share/doc/fp-docs/2.6.2/fcl/iostream
/usr/include/boost/tr1/tr1/iostream
/usr/include/c++/4.8/iostream
Seeing as how clang++ was keen on using g++ 4.9 files, I decided to install g++ 4.9
ubuntu does not have 4.9 as part of it's normal "sudo apt-get install g++". They are still on 4.8. (not sure what put the gcc 4.9 (but apparently not g++ 4.9) stuff on my system).
I found out that I could install g++ 4.9 by doing:
sudo add-apt-repository ppa:ubuntu-toolchain-r/test
sudo apt-get update
sudo apt-get install g++-4.9
After these commands were issued, clang++ was able to find <iostream>.
Try to install these packages,
sudo yum groupinstall "Development Tools"
sudo yum install libstdc++-static.x86_64 compat-libstdc++-33.x86_64
I have had this problem and it was solved installing these packages.

installing new version of libtool for -- libwebsocket warmcat

I am installing libwebsocket it is giving me error :---
http://git.warmcat.com/cgi-bin/cgit/libwebsockets/snapshot/libwebsockets-1.0-chrome25-firefox17.tar.gz
/pi/libwebsockets-1.0-chrome25-firefox17$ ./autogen.sh
Preparing the libwebsockets build system...please wait
Found GNU Autoconf version 2.69
perl: warning: Setting locale failed.
perl: warning: Please check that your locale settings:
LANGUAGE = "en_US:",
LC_ALL = (unset),
LANG = "en_US.UTF-8"
are supported and installed on your system.
perl: warning: Falling back to the standard locale ("C").
perl: warning: Setting locale failed.
perl: warning: Please check that your locale settings:
LANGUAGE = "en_US:",
LC_ALL = (unset),
LANG = "en_US.UTF-8"
are supported and installed on your system.
perl: warning: Falling back to the standard locale ("C").
Found GNU Automake version 1.13
Found GNU Libtool version 1.5.26
Automatically preparing build ... Warning: autoreconf failed
Attempting to run the preparation steps individually
Preparing build ... ERROR: aclocal failed
At present when i run libtool --version:---
/home/pi$ libtool --version
ltmain.sh (GNU libtool) 1.5.26 (1.1220.2.492 2008/01/30 06:40:56)
Copyright (C) 2008 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
If i run whereis command, i get following output :----
/pi/libtool-2.4.2$ whereis libtool
libtool:
I have to install libtool version 2.4.2, to get rid of above error.
Now i have installed 2.4.2 version for libtool :---
ftp://ftp.gnu.org/gnu/libtool/libtool-2.4.2.tar.gz
After installing 2.4.2 version of libtool, If i run whereis command, i get following output :----
/pi/libtool-2.4.2$ whereis libtool
libtool: /usr/local/bin/libtool
But if i run libtool --version:---
/home/pi$ libtool --version
ltmain.sh (GNU libtool) 1.5.26 (1.1220.2.492 2008/01/30 06:40:56)
Why libtool --version command is not showing the latest installed version of libtool 2.4.2?
Also i am getting same error for libwebsocket when i run ./autogen.sh .
Have you tried the latest version (1.22) using CMake? It's straight forward to build.
$ git clone git://git.libwebsockets.org/libwebsockets
$ cd libwebsockets/
Read README.build. Don't know the old version of libwebsockets, but I guess it's
now more towards using CMake rather than autotools.
$ mkdir build && cd build
$ cmake .. -DCMAKE_INSTALL_PREFIX:PATH=/usr/local
The last line is similar to:
$ ./configure --prefix=/usr/local
The whole thing built pretty quick and without any issue.

Resources