How do I install gcc 6.x on Oracle Solaris 11.2 x86 and CentOS 6.6 Final? - linux

I tried to install... but failed
$ wget https://ftp.gnu.org/gnu/gcc/gcc-6.2.0/gcc-6.2.0.tar.bz2
$ tar -jxvf gcc-6.2.0.tar.bz2
$ cd /home/logvadmin/gcc-6.2.0/
$ ./contrib/download_prerequisites
$ ./configure --prefix=/usr/gcc-6.2.0 --enable-languages=c,c++ --disable-multilib
$ make
In phase 6 Error
[Solaris]
make: Fatal error in reader: Makefile, line 27: Unexpected end of line seen
$ vi Makefile
26: ifeq (,$(.VARIABLES)) # The variable .VARIABLES, new with 3.80, is never empty.
27: $(error GNU make version 3.80 or newer is required.)
28: endif
user#solaris:~/gcc-6.2.0$ gcc --version
gcc (GCC) 4.5.2
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.
[CentOS]
It takes too long to build.
6 hour ??
I dont know what the problem is..

As the comments point out, use gmake.
For full details, see https://gcc.gnu.org/install/index.html
I fairly regularly build GCC from SVN head on Solaris 11.3 amd64, Fedora 24 x64 and FreeBSD 11 x64.
Firstly, I built and installed libgmp, lbmpc and libmpfr to ~/tools/lib. You may not need to do this if you are using a recent Linux or FreeBSB. On Solaris, third party freeware is often many years out of data.
My configure script for Solaris is:
#!/bin/ksh93
export LD_RUN_PATH=/export/home/paulf/tools/lib/lib
../configure --prefix=/export/home/paulf/tools/gcc --with-gmp=/export/home/paulf/tools/lib --with-gnu-as --with-as=/usr/ccs/bin/gas --without-gnu-ld --with-ld=/usr/ccs/bin/ld
My update & build script is:
#!/bin/ksh
export LD_RUN_PATH=~/tools/lib/lib
cd ~/scratch/gcc
svn up
cd build
gmake -j 4
if (( $? == 0 )) ; then
print gmake succeeded
gmake install
fi
Note that if you don't set the run path then the default GCC build won't set it and you will have an essentially broken compiler that needs LD_LIBRARY_PATH

Related

-bash: ./ex1: cannot execute binary file: Exec format error [duplicate]

When I try to execute a 32-bit file compiled with gcc -m32 main.c -o main on Windows Subsystem for Linux, I get the following error: bash: ./main: cannot execute binary file: Exec format error.
If I compile it without -m32 it runs.
Any solution for running 32-bit executable on WSL?
QEMU and binfmt support light the way :)
https://github.com/microsoft/wsl/issues/2468#issuecomment-374904520
After reading that the WSLInterop between WSL and Windows processes used binfmt, I was tinkering with QEMU to try some ARM development, and incidentally discovered how to get 32-bit support working.
Edit: requires "Fall Creators Update", 1709, build 16299 or newer
Install qemu and binfmt config:
sudo apt install qemu-user-static
sudo update-binfmts --install i386 /usr/bin/qemu-i386-static --magic '\x7fELF\x01\x01\x01\x03\x00\x00\x00\x00\x00\x00\x00\x00\x03\x00\x03\x00\x01\x00\x00\x00' --mask '\xff\xff\xff\xff\xff\xff\xff\xfc\xff\xff\xff\xff\xff\xff\xff\xff\xf8\xff\xff\xff\xff\xff\xff\xff'
You'll need to reactivate binfmt support every time you start WSL:
sudo service binfmt-support start
Enable i386 architecture packages:
sudo dpkg --add-architecture i386
sudo apt update
sudo apt install gcc:i386
Try it out:
$ file /usr/bin/gcc-5
/usr/bin/gcc-5: ELF 32-bit LSB executable, Intel 80386, version 1 (SYSV), dynamically linked, interpreter /lib/ld-linux.so.2, for GNU/Linux 2.6.32, BuildID[sha1]=2637bb7cb85f8f12b40f03cd015d404930c3c790, stripped
$ /usr/bin/gcc-5 --version
gcc-5 (Ubuntu 5.4.0-6ubuntu1~16.04.9) 5.4.0 20160609
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 helloworld.c -o helloworld
$ ./helloworld
Hello, world!
$ file helloworld
helloworld: ELF 32-bit LSB executable, Intel 80386, version 1 (SYSV), dynamically linked, interpreter /lib/ld-linux.so.2, for GNU/Linux 2.6.32, BuildID[sha1]=3a0c7be5c6a8d45613e4ef2b7b3474df6224a5da, not stripped
And to prove it really was working, disable i386 support and try again:
$ sudo service binfmt-support stop
* Disabling additional executable binary formats binfmt-support [ OK ]
$ ./helloworld
-bash: ./helloworld: cannot execute binary file: Exec format error
32-bit ELF support isn't provided by WSL (yet). There doesn't seem to be any progress since the UserVoice was raised - you are out luck.
See UserVoice: Please add 32 bit ELF support to the kernel and Support for 32-bit i386 ELF binaries.
If possible, switch to a real Linux ;-)
Since this was originally posted, the support has been available on WSL2 which does support real Linux kernel! So that should be the preferred way.
As noted in the linked github issue, there's also qemu-user which can be used if WSL1 is still used.
WSL2 runs in a real virtual machine using a real Linux kernel, therefore it's actually possible to do anything a Linux VM can do, including running 32-bit code. Just install 32-bit libs by running
sudo dpkg --add-architecture i386
sudo apt-get update
For more information read
Announcing WSL 2
WSL 2 FAQ

Specify the expected Linux version of the output binary of GCC

I'm helping others doing a lab experiment of the "operating systems concepts" course. The experiment task is to compile Linux 2.6.26 and run it in QEMU.
After compiling the Linux kernel, we're told to write a smallest program to serve as the init program. The example we're presented (and we followed) is:
#include <stdio.h>
int main() {
while (1) {
puts("Hello!");
sleep(2);
}
}
The compilation command is:
root#ubuntu:/home/vmware/oslab# gcc --version
gcc (Ubuntu 4.8.4-2ubuntu1~14.04.4) 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.
root#ubuntu:/home/vmware/oslab# gcc -static -o init hello.c
The host environment should be a freshly-installed Ubuntu 14.04.6 (i386).
The problem is, one of my fellow students followed the instruction carefully, and the init program failed to execute. I asked him for his whole initrd.img, and noticed how his init program looks different:
vmware#ubuntu:~/oslab$ file mnt/init
mnt/init: ELF 32-bit LSB executable, Intel 80386, version 1 (GNU/Linux), statically linked, for GNU/Linux 2.6.32, BuildID[sha1]=7365ac494ef1d924c171899c169dbd3195d2d209, not stripped
To me, that's clearly not something that can run on Linux 2.6.26. With GCC 4.8 provided in the Ubuntu APT repository (trusty), how can I get GCC to output something that runs on Linux 2.6.26?
FYI: On my own testing VM (also Ubuntu 14.04.6, Linux 4.4, same latest GCC version from Ubuntu APT repo as of April 2, 2019), the compiled program shows Linux 2.6.24 in file output. Also, his binary runs perfectly well in QEMU with my freshly compiled 2.6.32.37 kernel.
Specify the expected Linux version of the output binary of GCC
in your question you speak about the version of libc C but that can also concerns a lot of other libs, and may be you want also produce 32b and/or 64b executable(s).
For me the most secure way is to use pbuilder, I use it to produce BoUML debs for Ubuntu Cosmic (18.10) Bionic (18.04), Artful (17.10) Zesty (17.04) Yakkety (16.10) Xenial (16.04) Trusty (14.04) and Precise (12.04) and that in both 32b and 64b, and I do all of that from my Ubuntu Xenial 64b just doing the appropriate sequence of pbuilder commands (without any reboot to go in each Linux release)
That needs time to generate a version but because this is made in the corresponding Linux version you are sure of the result.
The provided lab environment was Ubuntu 14.04, where the package libc6 has version 2.19-0ubuntu6.14.
The lab instruction provided by the teaching assistants contained an instruction to change the APT source by editing /etc/apt/sources.list manually, which had a SERIOUS disaster in it: The "version" string in the edited example was xenial instead of trusty, which, if followed, would factually update your system to Xenial (Ubuntu 16.04). The new version of libc6 was 2.23-0ubuntu11, which would cause as and ld (from binutils, not related to GCC) to output ELF with a minimum Linux version of 2.6.32.
With glibc version 2.19, the output ELF is compatible with Linux 2.6.24, but with glibc 2.23, the output is only compatible with Linux 2.6.32.
I tested and verified this by compiling a test program under Ubuntu 14.04 and checking the ELF information, then replaced all trusty with xenial, did apt-get update and only updated binutils and its dependencies (which includes libc6), and compiled the program and checked it again.

how to find libstdc++.so.6: that contain GLIBCXX_3.4.19 for RHEL 6?

I work with a Linuxs server:
> cat /etc/redhat-release
Red Hat Enterprise Linux Server release 6.7 (Santiago)
(from wikipedia:
Red Hat Enterprise Linux 6 was forked from Fedora 12
6.7, also termed Update 7, 22 July 2015 (kernel 2.6.32-573)
6.8, also termed Update 8, 10 May 2016 (kernel 2.6.32-642))
The kernel
> uname -r
2.6.32-642.11.1.el6.x86_64
> uname -s
Linux
> uname -v
#1 SMP Tue Nov 15 22:57:18 EST 2016
> cat /proc/version
Linux version 2.6.32-642.11.1.el6.x86_64 (sandman#node3res7) (gcc version 4.4.7 20120313 (SuSE 4.4.7-17) (GCC) )
#1 SMP Tue Nov 15 22:57:18 EST 2016
gcc version
> gcc --version
gcc (GCC) 4.4.7 20120313 (SuSE 4.4.7-17)
when trying to install Tensdorflow, I have some issue with a missing library:
ImportError: /usr/lib64/libstdc++.so.6: version `GLIBCXX_3.4.19' not found (required by /opt/ccda/anaconda2/envs/tensorflow35/lib/python3.5/site-packages/tensorflow/python/_pywrap_tensorflow.so)
As you can see in my lib64/libstdc++.so.6 I don't have GLIBCXX_3.4.19
strings /usr/lib64/libstdc++.so.6 | grep GLIBCXX
GLIBCXX_3.4
GLIBCXX_3.4.1
....
GLIBCXX_3.4.12
GLIBCXX_3.4.13
GLIBCXX_FORCE_NEW
GLIBCXX_DEBUG_MESSAGE_LENGTH
I look with the following command:
yum whatprovides */libstdc++.so.6
...
libstdc++-4.4.7-17.el6.x86_64 : GNU Standard C++ Library
Repo : installed
Matched from:
Filename : /usr/lib64/libstdc++.so.6
so my question where can I find the libstdc++-4.x.y-z.el6.x86_64 that contain GLIBCXX_3.4.19 and that I could install on my server RHEL 6 with my gcc version ?
I am a little bit confuse of which version to use from this page
https://www.rpmfind.net/linux/rpm2html/search.php?query=libstdc%2B%2B.so.6%28GLIBCXX_3.4.19%29&submit=Search+...&system=&arch=
I don't see a version for Fedora 12 or RHEL6
I need arch x86_64
I need I guess something gcc (GCC) 4.4.7
I guess I need 64bit
I the following a good macth ? I am quite confuse by the name and info:
libstdc++6-gcc48-32bit-4.8.5-21.1.x86_64.html The standard C++ shared library OpenSuSE leap updates for 42.1 libstdc++6-gcc48-32bit-4.8.5-21.1.x86_64.rpm
I don't have Internet access on the server so I need to download the file locally copy it on the server and do the intsallion.
Thanks for your help
Cheers
Fabien
ps: bonus question
SuSE 4.4.7-17 (GCC), I am confuse, I understood that Suse was a Linux distribution like Redhat!
I found a solution here:
https://www.linuxquestions.org/questions/red-hat-31/lib-libstdc-so-6-version-%60glibcxx_3-4-15'-not-found-4175419985/
Replacing libstdc++-so.6 with a later version that works in EL6:
Unpack libstdc++6_4.7.1-2_i386.deb
http://ftp.de.debian.org/debian/pool...7.1-2_i386.deb
with : ar -x libstdc++6_4.7.1-2_i386.deb && tar xvf data.tar.gz
Next : 1) su ; 2) cp libstdc++.so.6.0.17 /usr/lib/
3) cd /usr/lib/ && rm libstdc++.so.6
4) ln -s libstdc++.so.6.17 libstdc++.so.6
Reason for suggesting the Debian package :
It's a ( gcc ) libstdc++ version that's compiled with a glibc
old enough to be used in EL6 / CentOS 6.
Updated steps (because it seems the file has been moved):
curl -O http://ftp.de.debian.org/debian/pool/main/g/gcc-4.7/libstdc++6-4.7-dbg_4.7.2-5_i386.deb
tar -x libstdc++6-4.7-dbg_4.7.2-5_i386.deb && tar xvf data.tar.gz
mkdir backup
cp /usr/lib/libstdc++.so* backup/
cp ./usr/lib/i386-linux-gnu/debug/libstdc++.so.6.0.17 /usr/lib
ln -s libstdc++.so.6.0.17 libstdc++.so.6
Previous link is dead now as well, you can use this one
http://ftp.de.debian.org/debian/pool/main/g/gcc-4.8/libstdc++6-4.8-dbg_4.8.4-1_i386.deb
In previous comment from Serge, there's a cd missing
cd /usr/lib/
Or like in my case
cd /usr/lib64
For RHEL6, this is in the Software Collections.
I think (without citation) the devtoolsets are numbered according to what version gcc is included. devtoolset 8 will give you gcc 8. Much higher than 4.7 or 4.8.
subscription-manager repos --enable rhel-server-dts-6-rpms
yum install devtoolset-8-gcc-c++
source scl_source enable devtoolset-8

nvcc + c2hs on OS X 10.9.5

I'm building a software that needs nvcc for compilation. I don't have a CUDA-capable GPU, but actually I don't need that – a friend is building the exact same software on Linux, he has no CUDA GPU, but everything's fine.
I installed the newest CUDA toolkit from https://developer.nvidia.com/cuda-downloads (cuda_6.5.14_mac_64.pkg) without an issue. But as I was building the software I got into problems.
I was able to reproduce the issue on the smaller scale:
$ mkdir temp; cd temp; cabal sandbox init
$ cabal get cuda
Unpacking to cuda-0.6.5.0/
$ cd cuda-0.6.5.0/Foreign/CUDA/Analysis
$ c2hs -d trace --cpp=/Developer/NVIDIA/CUDA-6.5/bin/nvcc --cppopts=-ccbin --cppopts=/usr/bin/clang --cppopts=-Xcompiler --cppopts=--stdlib=libstdc++ Device.chs
Attempting to read file `Device.chs'...
...parsing `Device'...
...successfully loaded `Device'.
Invoking cpp as `/Developer/NVIDIA/CUDA-6.5/bin/nvcc -E -x c -ccbin /usr/bin/clang -Xcompiler --stdlib=libstdc++ -U__BLOCKS__ -DC2HS_MIN_VERSION(mj,mn,rv)=(mj<=0&&mn<=18&&rv<=2) Device.chs.h'...
In file included from <built-in>:170:
<command line>:3:29: error: expected comma in macro parameter list
#define C2HS_MIN_VERSION(mj 1
^
<command line>:5:11: warning: ISO C99 requires whitespace after the macro name [-Wc99-extensions]
#define rv) (mj<=0&&mn<=18&&rv<=2)
^
Device.chs.h:1:10: fatal error: 'cbits/stubs.h' file not found
#include "cbits/stubs.h"
^
1 warning and 2 errors generated.
c2hs: Error during preprocessing custom header file
With the trace in hand, I was able to go deeper into the rabbit hole:
$ /Developer/NVIDIA/CUDA-6.5/bin/nvcc -E -x c -ccbin /usr/bin/clang -Xcompiler --stdlib=libstdc++ -U__BLOCKS__ -DC2HS_MIN_VERSION(mj,mn,rv)=(mj<=0&&mn<=18&&rv<=2) Device.chs.h
zsh: parse error near `)'
$ /Developer/NVIDIA/CUDA-6.5/bin/nvcc -E -x c -ccbin /usr/bin/clang -Xcompiler --stdlib=libstdc++ -U__BLOCKS__ -D'C2HS_MIN_VERSION(mj,mn,rv)=(mj<=0&&mn<=18&&rv<=2)' Device.chs.h
# 1 "Device.chs.h"
# 1 "<built-in>" 1
# 1 "<built-in>" 3
# 170 "<built-in>" 3
# 1 "<command line>" 1
In file included from <built-in>:170:
<command line>:3:29: error: expected comma in macro parameter list
#define C2HS_MIN_VERSION(mj 1
^
<command line>:5:11: warning: ISO C99 requires whitespace after the macro name [-Wc99-extensions]
#define rv) (mj<=0&&mn<=18&&rv<=2)
^
# 1 "<built-in>" 2
# 1 "Device.chs.h" 2
Device.chs.h:1:10: fatal error: 'cbits/stubs.h' file not found
#include "cbits/stubs.h"
^
1 warning and 2 errors generated.
$ Developer/NVIDIA/CUDA-6.5/bin/nvcc -x c -D 'C2HS_MIN_VERSION(mj,mn,rv)=(mj<=0&&mn<=18&&rv<=2)' Device.chs.h
(same issue)
I have no idea how to fix that. By the way, both clang and gcc are okay with passing macros with arguments via -D.
Probably relevant:
$ echo $PATH
/Users/konrad/bin:/Users/konrad/.ghc-current/bin:/Users/konrad/.cabal/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Developer/NVIDIA/CUDA-6.5/bin
$ echo $DYLD_LIBRARY_PATH
/Developer/NVIDIA/CUDA-6.5/lib:
$ echo $LD_LIBRARY_PATH
/usr/local/cuda/lib:
$ ghc --version
The Glorious Glasgow Haskell Compilation System, version 7.8.3
$ cabal --version
cabal-install version 1.20.0.3
using version 1.20.0.0 of the Cabal library
$ c2hs --version
C->Haskell Compiler, version 0.18.2 The shapeless maps, 31 Oct 2014
build platform is "x86_64-darwin" <1, True, True, 1>
$ gcc --version
Configured with: --prefix=/Applications/Xcode.app/Contents/Developer/usr --with-gxx-include-dir=/usr/include/c++/4.2.1
Apple LLVM version 6.0 (clang-600.0.51) (based on LLVM 3.5svn)
Target: x86_64-apple-darwin13.4.0
Thread model: posix
$ gcc-4.9 --version
gcc-4.9 (GCC) 4.9.0 20140411 (prerelease)
Copyright (C) 2014 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.
I have Intel Iris Pro 5100 (mbp retina 15" late 2013).
As per https://github.com/haskell/c2hs/issues/111, on November 21 a change was pushed to c2hs HEAD to work around the issue, which was caused by an upstream quirk in nvcc. So at this point, using the latest c2hs should indeed work.

Compiling linux source to windows 7 w/ makefile.in

I have the source for a linux-based program, but trying to run in Win7 environment. I found software called "mingw32" and msys that can compile linux source to win7 using makefile.in (included with source). But I get error "nothing to be done for 'makefile.in'"
Source is available here: http://sourceforge.net/projects/libots/files/libots/ots-0.5.0/ots-0.5.0.tar.gz/download
Makefile.in is below
# Makefile.in generated automatically by automake 1.4-p6 from Makefile.am
# Copyright (C) 1994, 1995-8, 1999, 2001 Free Software Foundation, Inc.
# This Makefile.in is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
# with or without modifications, as long as this notice is preserved.
[...]
POPT_LIBS = #POPT_LIBS#
POPT_REQUIRED = #POPT_REQUIRED#
RANLIB = #RANLIB#
RC = #RC#
STRIP = #STRIP#
VERSION = #VERSION#
VERSION_INFO = #VERSION_INFO#
[...]
lib_LTLIBRARIES = libots-1.la
[...]
libots-1.la: $(libots_1_la_OBJECTS) $(libots_1_la_DEPENDENCIES)
$(LINK) -rpath $(libdir) $(libots_1_la_LDFLAGS) $(libots_1_la_OBJECTS) $(libots_1_la_LIBADD) $(LIBS)
[...]
# Tell versions [3.59,3.63) of GNU make to not export all variables.
# Otherwise a system limit (for SysV at least) may be exceeded.
.NOEXPORT:
You need msys to run ./configure
Call msys.bat
cd to your e.g. c:\msys\1.0\src\ots-0.5.0 folder
run ./configure
you need also popt-1.5 . So if you don't have it , you have to download and build it first.
It's not that easy to build with mingw .
I would suggest first of all, download , the binary version for windows. If it runs without problems on your system, you can try to build it yourself. Ots-0.4.2-Win32-binary.zip
I doubt that this binary version works without error.
If you have time (3 days will not be enough)
you can download popt-1.8-1-src.zip .
But you must have also see line : configure:20043: checking for glib-2.0 >= 2.0 libxml-2.0 >= 2.4.23
and more.

Resources