Compiling againts especific version of armhf g++ - c++

I'm doing a crossbuild of a QT app from a Debian (Stretch) PC to a Debian (Jessie) BeagleBone Black, and when I executed this, I got the message
/home/bbuser/totemguard/totemguard: /usr/lib/arm-linux-gnueabihf/libstdc++.so.6: version `GLIBCXX_3.4.22' not found (required by /home/bbuser/totemguard/totemguard)
I saw that the armhf g++ version was 6.1 so I install the 4.9.2-10 (the same that I had on the BeagleBone Black) and recompiled my code, with similar result (different GLIBXX version):
/home/bbuser/totemguard/totemguard: /usr/lib/arm-linux-gnueabihf/libstdc++.so.6: version `GLIBCXX_3.4.21' not found (required by /home/bbuser/totemguard/totemguard)
Reading the ABI Policy and Guidelines, the G++ version for GLIBCXX_3.4.21 is 5.1.0:
GCC 4.9.0: GLIBCXX_3.4.20, CXXABI_1.3.8
GCC 5.1.0: GLIBCXX_3.4.21, CXXABI_1.3.9
GCC 6.1.0: GLIBCXX_3.4.22, CXXABI_1.3.10
But I never had the 5.1 version installed on my host PC or BeagleBone Black board.
Listing the /usr/lib/arm-linux-gnueabihf/ directory we can see that there are only the GCC 4.9.0 and GCC 6.1.0 libstdc++ version:
lrwxrwxrwx 1 root root 19 ago 3 15:53 libstdc++.so.6 -> libstdc++.so.6.0.22
-rw-r--r-- 1 root root 658064 dic 27 2014 libstdc++.so.6.0.20
-rw-r--r-- 1 root root 1019632 ago 3 15:53 libstdc++.so.6.0.22
This problem begin after a distro-upgrade from jessie to stretch, and I can't upgrade the beaglebone black gcc version.
What can I do?
EDIT 1:
On a test board (BeagleBone Black) I added the stretch repository and did this:
bbuser#beaglebone:~/totemguard$ sudo apt-cache policy libstdc++6
libstdc++6:
Installed: 4.9.2-10
Candidate: 6.1.1-11
Version table:
6.1.1-11 0
500 http://ftp.us.debian.org/debian/ stretch/main armhf Packages
*** 4.9.2-10 0
500 http://ftp.us.debian.org/debian/ jessie/main armhf Packages
100 /var/lib/dpkg/status
bbuser#beaglebone:~/totemguard$ sudo apt-get install libstdc++6
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following extra packages will be installed:
gcc-6-base
The following NEW packages will be installed:
gcc-6-base
The following packages will be upgraded:
libstdc++6
1 upgraded, 1 newly installed, 0 to remove and 726 not upgraded.
Need to get 517 kB of archives.
...
And the application ran fine (not 100% tested, but give no errors). Still this is a test board and I cant do the same on a production board.

solution 1) use -static (full libraries) or compile-in only libstdc++ as static to the binary
solution 2) distribute the appropriate libstdc++ version with the binary (possibly using LD_PRELOAD)
solution 3) use exactly the same g++ libstdc++ version for crosscompiling (at least matching)
usually better is to use solution 1) - you will have no problems across distros upgrade

Related

Deno on CentOS 7: 'GLIBC_2.18' not found

How to run Deno on Webfaction's CentOS 7 (64-bit)?
It gives an error:
deno: /lib64/libc.so.6: version `GLIBC_2.18' not found (required by deno)
Current Deno release 1.0.0 (latest today) is not compatible with CentOS 7.
I tried on the latest distribution released on 27 April 2020:
$ cat /etc/redhat-release
CentOS Linux release 7.8.2003 (Core)
This issue 7 GLIBC_2.18 not found suggests that there should be a way to solve this problem, but the thread seems to be abandoned for a year.
As of today Deno requires GLIBC_2.18, but unfortunately CentOS 7 is running 2.17, an old version of the gclib which is not enough:
$ ldd --version
ldd (GNU libc) 2.17
If you need to run Deno on CentOS you'll need to use CentOS 8. Tested it and it works.
From How to fix “/lib/x86_64-linux-gnu/libc.so.6: version `GLIBC_2.14' not found”:
That means the program was compiled against glibc version 2.14, and it
requires that version to run, but your system has an older version
installed. You'll need to either recompile the program against the
version of glibc that's on your system, or install a newer version of
glibc (the "libc6" package in Debian).
It will not happen for CentOS 7. From glibc_2.18 on Centos 7:
No. Never going to happen. We ship glibc 2.17 as part of CentOS 7 and
that will never change. It's part of the basic RHEL standards that
stuff like this does not change within a major version.
I wouldn't count on Deno — which is a new technology — to backport with old compilers. Consider upgrading your servers to CentOS 8.
For me, I have no way to upgrade the OS as it's managed by IT department. Seems there's a workaround. I found the link on the following thread does work.
https://github.com/denoland/deno/issues/1658#issuecomment-632986792

C++17 std::variant header file (clang 6.0.0)

Update
I narrowed down the problem to (probably! it's not entirely clear, even reading all I could find about the topic) that installing stdlibc++-7-dev would provide me with suitable (i.e., C++17-compliant) STL headers and libraries.
This (also, apparently) comes bundled with Ubuntu 17.04 (artful?) but is not available for xenial (Ubuntu 16.04.3 LTS) which is what I'm using.
I have tried downloading the individual .deb packages and installing them, but it quickly becomes a maze of unresolved dependencies.
If anyone could point me to how to install libstdc++-7-dev on 16.04, I'd be most grateful.
Original question
I have just installed clang++ 6.0 in Ubuntu 16.04 via the package manager (following these instructions) and all seems well: /usr/bin/clang++-6.0 works just fine, and if I try to use something that only works in C++17 (non-type template arguments with auto, see here) it compiles and runs, once I set CMAKE_CXX_COMPILER=/usr/bin/clang++-6.0 -- while it fails when I don't.
So... clang 6.0 understands C++17 as advertised (doh!) but when I use:
#include <variant>
the file is not found where I would expect it to be:
$ ll /usr/include/clang/6.0.0/
total 0
lrwxrwxrwx 1 root root 45 Aug 6 21:32 include -> ../../../lib/llvm-6.0/lib/clang/6.0.0/include
or anywhere else I can think of.
Would anyone know (a) whether it's supposed to be there at all and (b) if so, where do I go find it?
Update
I have double-checked that I have the latest (I think) stdc++ library:
$ sudo apt-get install libstdc++-5-dev
Reading package lists... Done
Building dependency tree
Reading state information... Done
libstdc++-5-dev is already the newest version (5.4.0-6ubuntu1~16.04.4).
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
and same for libstdc++-6-dev; also, I have libc++-dev:
$ sudo apt-get install libc++-dev
Reading package lists... Done
Building dependency tree
Reading state information... Done
libc++-dev is already the newest version (3.7.0-1).
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
Still, the variant.h* file is nowhere to be found.
Anything else I should try?
Yes, clang 5.0 (or rather, the libc++ that will ship as part of clang 5) has the <variant> header. But you need to be sure that you have installed libc++.
And as #KayEss mentioned, you'll need to pass -std=c++17 (or the earlier version of the same flag -std=c++1z) because variant is a C++17-only feature.

Installing g++ 7.0.1 on Debian 8.7

I have been trying for quite some time to install g++ 7 on my Debian machine. I was able to install it quite easily on my mac (as homebrew had a formula for it). However I cannot seem to find a way to install it on Linux.
This individual had a thread on installing g++ 4.9, and changing the url he gave led me to this page, which seems to be in the right direction... But I imagine installing it this way might lead to a few potential problems down the road when I wish to update these packages.
Is there a source I'm missing? Or is there maybe a place where I can download and compile everything I need to get it running?
Thank you for your help.
Helpful Data:
My kernel is x86_64 Linux 3.16.0-4-amd64.
Edit: After following Dietrich's advice, I am now met with a new error:
Reading package lists... Done
Building dependency tree
Reading state information... Done
Some packages could not be installed. This may mean that you have
requested an impossible situation or if you are using the unstable
distribution that some required packages have not yet been created
or been moved out of Incoming.
The following information may help to resolve the situation:
The following packages have unmet dependencies:
gcc-7 : Depends: cpp-7 (= 7-20170316-1) but it is not going to be installed
Depends: libcc1-0 (>= 7-20170316-1) but it is not going to be installed
Depends: binutils (>= 2.28) but 2.25-5+deb8u1 is to be installed
Depends: libgcc-7-dev (= 7-20170316-1) but it is not going to be installed
Depends: libisl15 (>= 0.15) but it is not installable
Depends: libmpfr4 (>= 3.1.3) but 3.1.2-2 is to be installed
Depends: libstdc++6 (>= 5) but 4.9.2-10 is to be installed
E: Unable to correct problems, you have held broken packages.
This is how my sources.list is set up:
#------------------------------------------------------------------------------#
# OFFICIAL DEBIAN REPOS
#------------------------------------------------------------------------------#
###### Debian Main Repos
deb http://ftp.us.debian.org/debian/ jessie main contrib non-free
deb-src http://ftp.us.debian.org/debian/ jessie main contrib non-free
###### Debian Update Repos
deb http://security.debian.org/ jessie/updates main contrib non-free
deb http://ftp.us.debian.org/debian/ jessie-proposed-updates main contrib non-free
deb-src http://security.debian.org/ jessie/updates main contrib non-free
deb-src http://ftp.us.debian.org/debian/ jessie-proposed-updates main contrib non-free
###### For ffmpeg
deb http://www.deb-multimedia.org jessie main non-free
###### For gcc-7 (Experimental)
deb http://httpredir.debian.org/debian experimental main
I'm guessing this is, as you said, a problem with me being on Debian stable? What would I need to do in order to fix this error, while remaining on stable?
Edit 2: Okay, so I figured out that last error. I just had to add go through for every individual dependency that gave my trouble and install it using apt-get install -t testing . Thank you to everyone who replied. You were all very helpful.
You can find similar in the Stack Overflow Unix pages
To install the newest g++ from testing on debian, do the following:
Add debian testing repo to your apt sources by creating a file (with .list extension) on /etc/apt/sources.list.d folder containing the line
deb http://ftp.us.debian.org/debian testing main contrib non-free
Instruct debian to use testing sources on certain packages by creating a file on /etc/apt/preferences.d containing the following:
Package: *
Pin: release a=testing
Pin-Priority: 100
You should name the file something like preferences or testingpref,etc. If you have a preferences file, you can add it there. Remove the .unused or any . in the filename.
Update database:
sudo apt-get update
Install g++:
sudo apt-get install -t testing g++
This will give you the most recent version of g++ in the repo. Thus it will receive updates and more-easily reversable. You need to use -t testing to get most recent versions.
You may have dependency issues. It may be in experimental instead of testing for your architecture. See https://packages.debian.org/search?keywords=g%2B%2B
For experimental packages (7 is in there) add:
deb http://httpredir.debian.org/debian experimental main
to /etc/apt/sources.list . Similar to above.. pinning should say a=experimental instead of a=testing and lastly,
sudo apt-get install -t experimental g++
Good luck.
The kernel is irrelevant.
GCC 7 has not been released yet, as you can see in the GCC 7 release notes:
Disclaimer: GCC 7 has not been released yet, so this document is a work-in-progress.
You may want to learn about what makes different Linux distros different. In particular, what a rolling distribution is, and how Debian releases work. In a rolling distribution, all of the packages continually get updated to newer versions. Debian 8.7 (Jessie / stable) is not a rolling distribution. The packages versions are frozen and only updated when necessary, for extra stability. The latest version of GCC on Debian 8.7 is GCC 4.9.
Debian 9.0 (Stretch / testing) is a rolling release, at least until it gets frozen. If you switch your computer to Stretch you will get GCC 6.3.
If you need something newer, you can either switch to Sid (unstable), or pin packages from Sid.
However, GCC 7 is only available in experimental because it hasn't been released yet. You can install a single package from experimental if you like, see Debian Experimental for instructions.
Howto
Add to your /etc/apt/sources.list
https://wiki.debian.org/DebianExperimental
Then
apt-get update
apt-get -t experimental install gcc-7
From the page you must download the g++7 for amd64 deb file. Then, as root, run the following command.
dpkg -i file.deb

How to install GCC 5.1 on Linux (Ubuntu)

I'd like to experiment with the new GCC 5.1 C++ compiler on Ubuntu.
How can I install GCC 5.1 on Ubuntu?
I'd prefer some form of pre-built executable that I could just download and install, instead of downloading GCC's sources and building the whole GCC 5.1 from them.
Moreover, since I read libstdc++'s ABI changed in GCC 5, must a new version of libstdc++ be installed with GCC 5.1, too?
Package g++-5 (gcc version 5.2.1) is available in debian testing or in ubuntu wily. Previous milestones are 4.9 and 4.8. It would be more difficult to get a version in between, like 5.1.
If still satisfied with 5.2.1 then add this line to /etc/apt/sources.list:
deb http://ftp.debian.org/debian/ stretch main
Try to install package and its dependencies:
# apt-get update
# apt-get install g++-5
Then hope it is going to be installed without problems.
(It strongly depends which ubuntu version is used on host.)
A g++-4.9 install from stable debian (jessie) to ubuntu trusty (gcc 4.8) has been successful for me. When done comment out previously added line from sources list and
# apt-get update
If you are fond of eternal upgrades then set an apt pinning rule instead.

MAC OSX LION: gcc on mac not compiling wget

I am trying to install lynx / wget on my mac. and installation requires gcc to compile. I have gcc in my /usr/local/bin dir. I see that it is very much there.
spankincubus:Downloads spankincubus$ gcc -v
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/usr/local/libexec/gcc/x86_64-apple-darwin11.0.0/4.6.1/lto- wrapper
Target: x86_64-apple-darwin11.0.0
Configured with: ../gcc-4.6.1/configure --enable-languages=fortran,c++
Thread model: posix
gcc version 4.6.1 (GCC)
But when i run a configure utility for wget, i get an error. Any idea?? I'm not a gcc expert for the record.
checking whether make sets $(MAKE)... no
checking build system type... i386-apple-darwin11.4.2
checking host system type... i386-apple-darwin11.4.2
checking for gcc... gcc
checking whether the C compiler works... no
**configure: error: in `/usr/local/bin/wget-1.14':
configure: error: C compiler cannot create executables
See `config.log' for more details**
This is how my gcc looks
-rwxr-xr-x 1 root wheel 91368 Jul 23 2011 gcov
-rwxr-xr-x 1 root wheel 462124 Jul 23 2011 cpp
-rwxr-xr-x 1 root wheel 462060 Jul 23 2011 gcc
Honestly, even though it appears that gcc exists; but does it point to a valid install? It still sounds like it is not installed properly and with an upgrade to Mountain Lion, all your open source tools have been scrubbed away and pushed to Xcode and must be manually installed if necessary.