Armel cross-compilation on Debian (toolchain repository problem) - c++

I am compiling some code from armel architecture using Debian toolchain. I have found this page https://wiki.debian.org/CrossToolchains however, when I am failing to get an archive toolchain key using command from the instructions:
curl http://emdebian.org/tools/debian/emdebian-toolchain-archive.key | sudo apt-key add -
Seems that repository http://emdebian.org/tools/debian is not available anymore. Does anybody knows is there any issues with is now?
Thanks in advance.

As it explains on the debian page, the Emdebian is not supported anymore and it is suggested to use CrossToolchains package instead.
Based on this page, you may use arm-linux-gnueabihf as it supports ARM v6 and v7 as you need.

Related

How to install a newer version of libstdc++ on Centos 7

I am running an application and it throws me an error saying:
"C++ header 'string_view' is required. You need to install a newer libstdc++ on the host system."
Can someone guide me on what I need to do to get a newer version of "libstdc++" on my machine?
Thanks
Try running yum provides libstdc++ to show you what package provided the library on your system. You can then check if those packages are available for update using yum list available | grep <that package> followed by yum update <that package>.
Facing the same issue, I built gcc from source. This way you get to choose your own version. It's actually pretty straightforard -- see Building GCC at https://gcc.gnu.org/wiki/InstallingGCC.

Install older gcc/g++ versions in CentOS 8

I've been struggling with this for the past 2h. In CentOS 8 I can't find the devtoolset packages to install older gcc/g++ versions. There is no longer a scl repo for CentOS 8. I need gcc/g++ 4.9x installed along the current gcc/g++ 8.x and I need to be able to switch between the two. This was extremely easy to set up in Ubuntu, not the case in CentOS and the documentation is non-existent or I had trouble finding it.
If you wish to install an older gcc than the distro provides, you will need to compile it for source.
There is some guidance below on how to download and build an old GCC
https://bytefreaks.net/gnulinux/downgrade-gcc-on-centos-7-0-64bit-to-version-4-8-2
Found a solid path that has automated compiling and packaging gcc, as well as a guide:
Guide:
https://bobsteagall.com/2017/12/30/gcc-builder/
Github repo:
https://github.com/BobSteagall/gcc-builder
I won't copy paste what's in this person's guide as they deserve the credit. However, here's a summary of the steps:
Install your prereqs (rpm build tools, devtools for bootstrapping your environment).
Clone the repo.
Checkout a branch in the repo like the major version of GCC you want (e.g. gcc7).
In the repo, edit gcc-build-vars.sh such that it points to a version of GCC you want from http://gnu.mirror.constant.com/gcc/.
Perform the build with: ./build-gcc.sh -T | tee build.log.
Stage it: ./stage-gcc.sh.
Package it: (./pack-gcc.sh or ./make-gcc-rpm.sh -v).

How to get "g++ -mx32" to work on RHEL 7.2

I am new to x64_86, but forced to use it because RedHat dropped its 32-bit OS support in RHEL 7.x. I have to complile a lot of code, and am not ready to jump to x64 yet (because I do not need 64-bit addresses and do not want to face all related porting issues). So I have considered using -m32 and -mx32, and decided that -mx32 is the best route for me. However, while -m32 works fine on my build machine, when I use -mx32, I get this error:
In file included from /usr/include/features.h:399:0,
from /usr/include/string.h:25,
from zz.cpp:1:
/usr/include/gnu/stubs.h:13:28: fatal error: gnu/stubs-x32.h: No such file or directory
# include <gnu/stubs-x32.h>
^
compilation terminated.
I searched the web for solutions and some links indicate that I have to install some mysterious "multilib" rpms for g++ and gcc, however, I cannot find these anywhere. Others suggest that I have to install Linux in the x32 mode and build libgcc for x32, which sound extreme. Any ideas or leads? Did someone actually try g++ -mx32? Maybe it is not even supported on the RH platform... Thanks!
P.S. In order to get the "-m32" option to work I had to install:
yum install glibc-devel.i686 libgcc.i686 libstdc++-devel.i686 ncurses-devel.i686
This one fails (yum cannot find these RPMs) - allegedly these are required for -mx32 to work:
yum install gcc-multilib g++-multilib
:(
Multilib is indeed your answer, but do not know why your repo does not support it. I installed mine via apt-get:
sudo apt-get install gcc-multilib
Although it uses 64-bit instructions, it uses the 32-bit ABI so annoyingly will not run under WSL (Windows Linux subsystem), which only supports the 64-bit one.

how do i build gcc on a mac?

I'd like to build the latest version of gcc on a mac. I have the latest xcode but I'm looking for some of the c++0x features that are in more recent versions (the lambda functions, etc).
Are there any good step-by-step tutorials on doing this?
You should look at the Homebrew project.
Homebrew allows you to do things like this:
brew install gcc
Mac homebrew installation instructions are available here.
Add GCC support to a fresh Xcode 4.2 installation using this homebrew formula:
brew install https://raw.github.com/Homebrew/homebrew-dupes/master/apple-gcc42.rb
Upgrading from Xcode 4.1 doesn't drop existing GCC support, so this formula is only useful if you're working with a fresh 4.2+ installation.
One option is to install MacPorts and install the gcc46 package:
sudo port install gcc46
Another option is to download the source code and build it as follows:
tar xzvf gcc-4.6.0.tar.gz
cd gcc-4.6.0
./configure
make
Note that GCC 4.6.0 requires as prerequisites GMP 4.2+, MPFR 2.3.1+, and MPC 0.8.0+. If ./configure fails, it's probably because you're missing one of these (though it should give you a helpful error message in any case).
Building will take a while—likely several hours, depending on your hardware.
I would suggest building it yourself (Adam details how to do so). This will give you fine control on where to install and all the options you want to select. My experience from having multiple versions of gcc is that, if care is not taken apple's version of gcc can be damaged.
To speed up gcc installation you might want to look at --enable-languages option. If there are languages you don't need installed with the new gcc then you may not want to select them.

How do I install g++ on MacOS X?

I want to compile C++ code on MacOS X, using the g++ compiler. How do I install it?
That's the compiler that comes with Apple's XCode tools package. They've hacked on it a little, but basically it's just g++.
You can download XCode for free (well, mostly, you do have to sign up to become an ADC member, but that's free too) here: http://developer.apple.com/technology/xcode.html
Edit 2013-01-25: This answer was correct in 2010. It needs an update.
While XCode tools still has a command-line C++ compiler, In recent versions of OS X (I think 10.7 and later) have switched to clang/llvm (mostly because Apple wants all the benefits of Open Source without having to contribute back and clang is BSD licensed). Secondly, I think all you have to do to install XCode is to download it from the App store. I'm pretty sure it's free there.
So, in order to get g++ you'll have to use something like homebrew (seemingly the current way to install Open Source software on the Mac (though homebrew has a lot of caveats surrounding installing gcc using it)), fink (basically Debian's apt system for OS X/Darwin), or MacPorts (Basically, OpenBSDs ports system for OS X/Darwin) to get it.
Fink definitely has the right packages. On 2016-12-26, it had gcc 5 and gcc 6 packages.
I'm less familiar with how MacPorts works, though some initial cursory investigation indicates they have the relevant packages as well.
Installing XCode requires:
Enrolling on the Apple website (not fun)
Downloading a 4.7G installer
To install g++ *WITHOUT* having to download the MASSIVE 4.7G xCode install, try this package:
https://github.com/kennethreitz/osx-gcc-installer
The DMG files linked on that page are ~270M and much quicker to install. This was perfect for me, getting homebrew up and running with a minimum of hassle.
The github project itself is basically a script that repackages just the critical chunks of xCode for distribution. In order to run that script and build the DMG files, you'd need to already have an XCode install, which would kind of defeat the point, so the pre-built DMG files are hosted on the project page.
Type g++(or make) on terminal.
This will prompt for you to install the developer tools, if they are missing.
Also the size will be very less when compared to xcode
Download Xcode, which is free with an ADC online membership (also free):
http://developer.apple.com/technology/xcode.html
xcode is now available for free from the app store. Just "buy it" (for free) and it will download. To get the command line tools go into preferences/downloads and "install command line compiler tools".
Instead of gcc you are using clang, but it works the same.
Here is how to do it on the newer mac chips and how to switch from clang(default) to g++
Install g++ through home-brew.
Check out the version you just installed, probably 12th or higher
You can make a symbolic link from g++-12 to g++
In order to do it, just type in your terminal:
sudo ln -s $(which g++-12) /usr/local/bin/g++.
Now open a new terminal and check your version again and you should see g++ instead of clang
g++ --version