gcc 4.7 on Fedora 23 with gcc 5.3.1 - c++

I need to install gcc 4.7.x on my fedora 23 in order to make Matlab compile the code. I also came across an error when I was trying to use Cuda which required gcc 4.9.x or lower.
I tried to compile gcc-4.7.4 from scratch but I get the following errors:
Makefile:4107: recipe for target 'all-stage1-gcc' failed
make[2]: *** [all-stage1-gcc] Error 2
make[2]: Leaving directory '/home/x/src/objdir'
Makefile:19334: recipe for target 'stage1-bubble' failed
make[1]: *** [stage1-bubble] Error 2
make[1]: Leaving directory '/home/x/src/objdir'
Makefile:903: recipe for target 'all' failed
make: *** [all] Error 2
I made a separate directory for configuration and building and I ran the configure as:
../gcc-4.7.4/configure --enable-languages=c,c++ --disable-multilib --prefix=$HOME/gcc-4.7.4
However I think the problem rises from the fact that I am using gcc-5.3.1 to compile gcc-4.7.4 but I have no idea how to fix it.
I noticed there is no packages available from dnf to install gcc-4.7.x either.

It looks like you put your build dir inside the source tree. Don't do that. Follow the wiki's instructions.
do not run ./configure from within the source directory, this is not supported. You need to run configure from outside the source directory, in a separate directory created for the build
It'll look something like this:
tar xzf gcc-4.7.4.tar.gz
cd gcc-4.7.4
./contrib/download_prerequisites
cd ..
mkdir objdir
cd objdir
$PWD/../gcc-4.7.4/configure --no-multilib --prefix=$HOME/gcc-4.7.4 --enable-languages=c,c++
make
make install

This question is a little dated now, but patching gcc/cp/cfns.gperf did the trick for me. See here: https://gist.github.com/joka90/bb8ef36aa755994d3b3d/. Built using gcc 5.3.1 under Fedora 23.
#Download and apply fix to be able to build gcc 4.7 with gcc 5.1
cd /path/to/build/gcc/source
wget https://patchwork.ozlabs.org/patch/504982/raw/ -O cfns-fix-mismatch-in-gnu_inline-attributes.patch
patch -p1 -i cfns-fix-mismatch-in-gnu_inline-attributes.patch

Related

Compile Lua 5.3 Mingw64 MSys2

I have installed mingw64 and MSYS2 from the official site (http://mingw-w64.org/doku.php) following the instructions. Added bin folders to win7 PATH var. Everything seems to work. I run this command from MSYS2:
gcc --version
and it works.
Now I´m trying to install Lua 5.3 (lua-5.3.1.tar.gz from lua.org). I decompressed the file using WinRAR. From MSYS2, I go to my Lua directory
cd /e/Programming/Libs/lua-5.3.1/
then I run the make command
mingw32-make mingw
But it doesn´t work. I got this message...
cd src && E:/Programming/mingw64/mingw64/bin/mingw32-make mingw
mingw32-make[1]: Entering directory 'E:/Programming/Libs/lua-5.3.1/src'
E:/Programming/mingw64/mingw64/bin/mingw32-make "LUA_A=lua53.dll" "LUA_T=lua.exe" \
"AR=gcc -std=gnu99 -shared -o" "RANLIB=strip --strip-unneeded" \
"SYSCFLAGS=-DLUA_BUILD_AS_DLL" "SYSLIBS=" "SYSLDFLAGS=-s" lua.exe
E:\Programming\mingw64\mingw64\bin\mingw32-make: invalid option -- =
E:\Programming\mingw64\mingw64\bin\mingw32-make: invalid option -- g
E:\Programming\mingw64\mingw64\bin\mingw32-make: invalid option -- u
E:\Programming\mingw64\mingw64\bin\mingw32-make: invalid option -- 9
E:\Programming\mingw64\mingw64\bin\mingw32-make: invalid option -- 9
E:\Programming\mingw64\mingw64\bin\mingw32-make: invalid option -- a
E:\Programming\mingw64\mingw64\bin\mingw32-make: unrecognized option '--strip-unneeded SYSCFLAGS=-DLUA_BUILD_AS_DLL SYSLIBS= SYSLDFLAGS=-s lua.exe'
Usage: mingw32-make [options] [target] ...
This program built for x86_64-w64-mingw32
Report bugs to <bug-make#gnu.org>
makefile:116: recipe for target 'mingw' failed
mingw32-make[1]: *** [mingw] Error 2
mingw32-make[1]: Leaving directory 'E:/Programming/Libs/lua-5.3.1/src'
makefile:55: recipe for target 'mingw' failed
mingw32-make: *** [mingw] Error 2
I dont want to download Lua binaries, I want to compile it myself
How can I fix this?
I was having the same issue. I looked at this page:
http://www.thijsschreijer.nl/blog/?p=863
What I saw was that I did not have c:\mingw\msys\1.0\bin in my path variable. I added it just after the MinGW\bin path and it worked fine then.

libtool error building thrift 0.9.1 on Ubuntu 13.04

Building thrift 0.9.1 (support C, C++, java, C#, perl, python) on Ubuntu 13.04 I am getting this error.
./configure run without any options, make run without any options...
Making all in test
make[2]: Entering directory `/home/dvb/sw/thrift-0.9.1/test'
Making all in nodejs
make[3]: Entering directory `/home/dvb/sw/thrift-0.9.1/test/nodejs'
make[3]: Nothing to be done for `all'.
make[3]: Leaving directory `/home/dvb/sw/thrift-0.9.1/test/nodejs'
Making all in cpp
make[3]: Entering directory `/home/dvb/sw/thrift-0.9.1/test/cpp'
Makefile:832: warning: overriding commands for target `gen-cpp/ThriftTest.cpp'
Makefile:829: warning: ignoring old commands for target `gen-cpp/ThriftTest.cpp'
/bin/bash ../../libtool --tag=CXX --mode=link g++ -Wall -g -O2 -L/usr/lib -o libtestgencpp.la ThriftTest_constants.lo ThriftTest_types.lo ../../lib/cpp/libthrift.la -lssl -lcrypto -lrt -lpthread
libtool: link: ar cru .libs/libtestgencpp.a .libs/ThriftTest_constants.o .libs/ThriftTest_types.o
ar: .libs/ThriftTest_constants.o: No such file or directory
make[3]: *** [libtestgencpp.la] Error 1
make[3]: Leaving directory `/home/dvb/sw/thrift-0.9.1/test/cpp'
make[2]: *** [all-recursive] Error 1
make[2]: Leaving directory `/home/dvb/sw/thrift-0.9.1/test'
make[1]: *** [all-recursive] Error 1
make[1]: Leaving directory `/home/dvb/sw/thrift-0.9.1'
make: *** [all] Error 2
dvb#dvb-u13:~/sw/thrift-0.9.1$
While this seems to be a defect in the 0.9.1 release tarball, it is not a problem in the top of tree pulled via git as of this afternoon.
The solution if one encounters this problem is to use a newer version of thrift by getting the source tree directly via git instead of downloading the tarball. The only difference in build is you will need to run bootstrap.sh before configure. This is well documented.
Note two additional helpful bits of data:
1. Configure to build --without-tests (Mike Johnson below - thanks)
2. This issue is fixed in 0.9.2 release (Luke below- thanks!)
I ran into this problem tonight and "fixed" it. The problem is that ar(1) can't find the .o files in the directory test/cpp/.libs. I'm sure that there's some missing magic in the Makefile.am in test/cpp, but I've neither the patience or automake-fu to fix that.
Instead, I just symlinked the .o files from test/cpp to test/cpp/.libs/. That fixes the build of the C++ tests.
cd thrift-0.9.1/test/cpp/.libs
for i in ../*.o; do echo $i; ln -s $i .; done
Thrift was since released with this compile problem. You can choose to skip compiling tests, instead:
./configure --without-tests
You can also try this:
./configure
(cd test/cpp; ln -s . .libs)
make install
This will simply link .libs back to test/cpp. "ar" will find the files there.
David V is right that 0.9.1 is broken but 0.9.2 works. The build instructions seem to be a broken link as well. So here are the commands that worked for me, from a fresh Ubuntu install:
# Install java if you don't have it
sudo apt-get install default-jre
# install build dependencies
sudo apt-get install libboost-dev libboost-test-dev libboost-program-options-dev libboost-system-dev libboost-filesystem-dev libevent-dev automake libtool flex bison pkg-config g++ libssl-dev
cd /tmp
curl http://archive.apache.org/dist/thrift/0.9.2/thrift-0.9.2.tar.gz | tar zx
cd thrift-0.9.2/
./configure
make
sudo make install
#test that it can run
thrift --help
(credit goes to these helpful instructions; I just replaced 0.9.1 with 0.9.2)
I happened to face this problem. You can try cp all test/cpp/*.o to .libs folder.
Or you can skip compiling tests.
cp test/cpp/*.o test/cpp/.libs/

Cannot open libmpc.so.3 while making gcc4.8.1

I want to install gcc4.8.1 on ubuntu 10.04.
Here are my installing steps:
Install libgmp, libmpfr and libmpc.
After switch to gcc4.8.1 source code dir, run "./configure --prefix=/usr/bin/gcc4.8.1 --with-gmp=/opt/pkg/gmp5.1.2 --with-mpfr=/opt/pkg/mpfr3.1.2 --with-mpc=/opt/pkg/mpc1.0.1"
make
export LD_LIBRARY_PATH=/opt/pkg/gmp5.1.2/lib:/opt/pkg/mpfr3.1.2/lib:/opt/pkg/mpc1.0.1/lib
sudo make install.
In the last step I get this error:
/usr/local/sbin/gcc-4.8.1/host-i686-pc-linux-gnu/gcc/cc1: error while loading shared libraries: libmpc.so.3: cannot open shared object file: No such file or directory
make[5]: *** [install-exec-hook] Error 1
make[5]: Leaving directory `/usr/local/sbin/gcc-4.8.1/i686-pc-linux-gnu/libjava'
make[4]: *** [install-exec-am] Error 2
make[4]: Leaving directory `/usr/local/sbin/gcc-4.8.1/i686-pc-linux-gnu/libjava'
make[3]: *** [install-am] Error 2
make[3]: Leaving directory `/usr/local/sbin/gcc-4.8.1/i686-pc-linux-gnu/libjava'
make[2]: *** [install-recursive] Error 1
make[2]: Leaving directory `/usr/local/sbin/gcc-4.8.1/i686-pc-linux-gnu/libjava'
make[1]: *** [install-target-libjava] Error 2
make[1]: Leaving directory `/usr/local/sbin/gcc-4.8.1'
make: *** [install] Error 2
I have switched to the libmpc library path and tested libmpc.so.3 with ldd. It has been installed successfully. Why does it say it cannot open shared object libmpc.so.3? How can I fix it?
According to your suggest, I have installed gcc4.8.1 successfully. Here are my steps:
Remove gmp, mpfr and mpc from /opt/pkg.
Install gmp, mpfr and mpc with the default configure. These packages will be installed in /usr/local/lib.
export LD_LIBRARY_PATH=/usr/local/lib:$LD_LIBRARY_PATH.
Enter the gcc source dir, run "./configure".
make.
Add symbol links:
sudo ln -s /usr/local/lib/libgmp.so.10 /usr/lib/libgmp.so.10
sudo ln -s /usr/local/lib/libmpfr.so.4 /usr/lib/libmpfr.so.4
sudo ln -s /usr/local/lib/libmpc.so.3 /usr/lib/libmpc.so.3
sudo make install.
Than you KiaMorot. Thank you trojanfoe.
I don't believe any of the answers here address the issue. Your problem is the last two steps
export LD_LIBRARY_PATH=/opt/pkg/gmp5.1.2/lib:/opt/pkg/mpfr3.1.2/lib:/opt/pkg/mpc1.0.1/lib
sudo make install
exporting your LD_LIBRARY_PATH is correct, but then you reset all environment variables when you change to root user with sudo in the last step.
One way to get around this:
sudo -s # become root user
export LD_LIBRARY_PATH=/opt/pkg/gmp5.1.2/lib:/opt/pkg/mpfr3.1.2/lib:/opt/pkg/mpc1.0.1/lib
make install # don't use sudo here
If anybody stumbles upon this using their own manually-built version of libgmp, libmpfr and libmpc instead of the system-provided ones:
export LD_LIBRARY_PATH=/opt/your-prefix-directory
is necessary for make itself, i.e. even when gcc ./configure was run with
--with-gmp=/opt/your-prefix-directory --with-mpc=/opt/your-prefix-directory --with-mpfr=/opt/your-prefix-directory
you need to specify where the linker should go looking for libgmp and friends.
You have to check if the libmpc.so.3 is a successfully created symbolic link to libmpc.so.3.0.0. This error may arise because you have installed this library manually and the sym. link may be missing. You could try this:
sudo ln -s /opt/pkg/mpc1.0.1/lib/libmpc.so.3.0.0 /opt/pkg/mpc1.0.1/lib/libmpc.so.3
Syntax of ln is ln -s <real path to file> <symbolic link name>. For more check out the man page of ln.

Can't compile Rust

I'm on Debian and following the compile instructions from the Rust wiki: https://github.com/mozilla/rust/wiki/Doc-getting-started
I tried a couple of times but it always ends up with the following error:
llvm[3]: Compiling opt.cpp for Release+Asserts build
make[3]: *** No rule to make target `/home/user/rust/llvm/x86_64-unknown-linux-
gnu/tools/lib/libLLVMipo.a', needed by `/home/user/rust/llvm/x86_64-unknown-
linux-gnu/Release+Asserts/bin/opt'. Stop.
make[3]: Leaving directory `/home/user/rust/llvm/x86_64-unknown-linux-gnu/
tools/opt'
make[2]: *** [opt/.makeall] Error 2
make[2]: Leaving directory `/home/user/rust/llvm/x86_64-unknown-linux-gnu/tools'
make[1]: *** [all] Error 1
make[1]: Leaving directory `/home/user/rust/llvm/x86_64-unknown-linux-gnu'
make: *** [/home/user/rust/llvm/x86_64-unknown-linux-gnu/Release+Asserts/
bin/llvm-config] Error 2
Edit:
The problem only occurs whithin a debootstrap/chroot environment, not within a full Debian Installation.
If you're referring to these instructions:
git clone git://github.com/mozilla/rust.git
cd rust
mkdir build
cd build
../configure
make check
...I can see at least one thing wrong with them. Try this instead:
git clone git://github.com/mozilla/rust.git
cd rust
git submodule update --init
./configure
make
sudo make install
The git submodule update --init is necessary to initialize Rust's submodules, which include LLVM and libuv.
git submodule update shouldn't be needed, as Rust's configure script tries to handle that itself, but if you run git submodule status and see lines about changes to src/libuv or src/llvm then it could be a problem.
I haven't seen that error before and can't tell what's wrong from that snippet. Possibly run make clean-all then gist the full output of ./configure && make, as well as the contents of config.mk. Also, you will probably get more attention with this question on the rust bug tracker: http://github.com/mozilla/rust/issues

Cannot build LLVM and Clang

I have tried to compile clang and llvm using the clang getting started manual. However, at step 5, when I do make, I get the following error. Any idea what is going on here, and how to fix it? Note that I am using Ubuntu 10.04 on a 64 bit x86 system.
cp: cannot stat `/home/MetallicPriest/Desktop/build/tools/clang/runtime/compiler-rt/clang_linux/full-x86_64/libcompiler_rt.a': No such file or directory
make[4]: *** [/home/MetallicPriest/Desktop/build/Debug+Asserts/lib/clang/3.1/lib/linux/libclang_rt.full-x86_64.a] Error 1
rm /home/MetallicPriest/Desktop/build/Debug+Asserts/lib/clang/3.1/lib/linux/.dir
make[4]: Leaving directory `/home/MetallicPriest/Desktop/build/tools/clang/runtime/compiler-rt'
make[3]: *** [compiler-rt/.makeall] Error 2
make[3]: Leaving directory `/home/MetallicPriest/Desktop/build/tools/clang/runtime'
make[2]: *** [all] Error 1
make[2]: Leaving directory `/home/MetallicPriest/Desktop/build/tools/clang'
make[1]: *** [clang/.makeall] Error 2
make[1]: Leaving directory `/home/MetallicPriest/Desktop/build/tools'
make: *** [all] Error 1
## Heading ##
The instruction given on this site work!
I had the same problem. As Eli suggested, I got the 3.0 release. It doesn't come with a 'getting started' but you can follow the INSTALL file from clang's root top.
You should be able to copy/paste the following (as root of course for the /usr/local/ part)
export NUMCPU=4 # or however many cores you want to paralell build with
export ORIGDIR=$PWD
wget http://llvm.org/releases/3.0/llvm-3.0.tar.gz
tar -zxf llvm-3.0.tar.gz
cd llvm-3.0.src/tools
wget http://llvm.org/releases/3.0/clang-3.0.tar.gz
tar -zxf clang-3.0.tar.gz
mv clang-3.0.src clang
cd $ORIGDIR
mkdir build
cd build
../llvm-3.0.src/configure --prefix=/usr/local
make -j$NUMCPU
cd tools/clang
make install
--
update, I should also note that following the 'getting started guide' with latest subversion (2012 09 10) actually does work , and i copy/pasted the lines exactly from the 'getting started' page http://clang.llvm.org/get_started.html (including 'optional' stuff) on a Fedora machine on ppc64.