Install g++ from source in Fedora 26 - c++

I am trying to install a c++ compiler on a IBM Power7 with Fedora 26.
In /usr/bin it is installed gcc [(GCC) 7.2.1 20170915 (Red Hat 7.2.1-2)] but it has not the c++ compiler (I tried gcc -lstdc++ but the result is: `
/usr/bin/ld: cannot find -lstdc++
I do not have sudo rights so I have to install everything from source.
I was able to install:
Zlib
Perl
Curl
Git
GNU M4
GMP
MPFR
MPC
EXPAT
APR and APR-UTIL
ISL
but when I try to install locally gcc, after a successfull configure, when I try make I got this error:
configure: error: in `/home/aantonietti/gcc/host-powerpc64-unknown-linux-gnu/gcc':
configure: error: C++ preprocessor "/lib/cpp" fails sanity check
See `config.log' for more details.
make[2]: *** [Makefile:4333: configure-stage1-gcc] Error 1
make[2]: Leaving directory '/home/aantonietti/gcc'
make[1]: *** [Makefile:23745: stage1-bubble] Error 2
make[1]: Leaving directory '/home/aantonietti/gcc'
make: *** [Makefile:945: all] Error 2
I also tried to install clang++ but it needs tons of other dependecies.
Do you have any hint on how to install just the gcc-c++ compiler?

Why don't you run dnf install gcc-c++? It will install the C++ system compiler bring in linking support for libstdc++ as well.

Related

Ipopt installation

I tried to install the Ipopt package on my Mac (macOS Catalina, 10.15.0) following this installation guide:
https://coin-or.github.io/Ipopt/INSTALL.html
I installed ASL as the linear solver and made it to the point 3. makewithout any further issues. However, when I run make test, I receive the following error message:
cd test; /Applications/Xcode.app/Contents/Developer/usr/bin/make test
CXX hs071_main.o
CXX hs071_nlp.o
CXXLD hs071_cpp
CC hs071_c.o
CCLD hs071_c
ln -s ../examples/hs071_f/hs071_f.f hs071_f.f
F77 hs071_f.o
F77LD hs071_f
ld: library not found for -lmkl_core
collect2: error: ld returned 1 exit status
make[1]: *** [hs071_f] Error 1
make: *** [unitTest] Error 2
Does anyone know how to fix this issue? It seems like it can't find the mkl library...
Yes, you have to install the Intel MKL library https://software.intel.com/content/www/us/en/develop/tools/oneapi/components/onemkl.html since it is not part of Mac OS.

gcc 4.7 on Fedora 23 with gcc 5.3.1

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

luarocks 'gcc-plugin.h' build error

I am trying to use torch together with the hdf5 package. I am trying to install it via luarocks install hdf5 but during the build phase I get an error regarding the gcc-plugin header. (gcc relies on clang backend). The complete error message is:
luarocks install --local hdf5
Installing https://luarocks.org/hdf5-2.0.0-1.src.rock...
Using https://luarocks.org/hdf5-2.0.0-1.src.rock... switching to 'build' mode
Warning: variable CFLAGS was not passed in build_variables
gcclua-config.h:1:10: fatal error: 'gcc-plugin.h' file not found
#include "gcc-plugin.h"
^
1 error generated.
env MACOSX_DEPLOYMENT_TARGET=10.8 gcc -c -o gcclua.o -Iplugin/include -fPIC -O2 -Wall -Wformat-security -I/usr/local/Cellar/lua/5.2.4_3/include gcclua.c
gcclua.c:7:10: fatal error: 'gcc-plugin.h' file not found
#include "gcc-plugin.h"
^
1 error generated.
make[2]: *** [gcclua.o] Error 1
make[1]: *** [gcc] Error 2
make: *** [gcc-lua] Error 2
Just to give more information, I am relying on
gcc --version
Configured with: --prefix=/Applications/Xcode.app/Contents/Developer/usr --with-gxx-include-dir=/usr/include/c++/4.2.1
xcrun: error: couldn't stat toolchain: '/Applications/Xcode.app/Contents/Developer/Toolchains/OSX10.11.xctoolchain' (errno=No such file or directory)
Apple LLVM version 7.3.0 (clang-703.0.29)
Target: x86_64-apple-darwin15.0.0
Thread model: posix
InstalledDir: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin
Does anybody has maybe a hint how to fix this issue?
Every help is greatly appreciated!!!
In addition to gcc, you need the headers, which on Linux you can get with sudo apt-get install gcc-4.8-plugin-dev. If you're on a different OS or version of gcc, just substitute the appropriate package manager / gcc version number.
gcc-plugin.h is a part of GCC, so I think you'll really need to install gcc to get that. Clang provides a gcc-compatible front-end script but that merely presents a command-line driver with compatible flags.
You should be able to install GCC using Homebrew: https://apple.stackexchange.com/a/86588
I bet you tried to work on a CS287-16 class :). I have contacted the developer of this library who wasn't that easy to do something to solve the problem. Apparently he has no friends who have a Mac PC... As a workaround I could suggest you to use a Docker container with Linux in it to run Lua scripts. That's what I have ended up with...
Here's the Docker image I was talking about: https://github.com/aoboturov/cs287-16-lua. You could build it yourself and the just run as a Docker container :)

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.

Error while compiling srilm in linux ubuntu 12.04

I am trying to install SRILM on my computer using os linux ubuntu 12.04, the gcc version 4.6.3 and the machine type is i686. at the end of the process it gives result of 2 errors as follows:
-o ../obj/i686/tclmain.o tclmain.cc
tclmain.cc:8:17: fatal error: tcl.h: No such file or directory
compilation terminated.
make[2]: * [../obj/i686/tclmain.o] Error 1
make[2]: Leaving directory /home/supriadi/workspace/srilm/misc/src'
make[1]: *** [release-libraries] Error 1
make[1]: Leaving directory/home/supriadi/workspace/srilm'
make: * [World] Error 2
what should I do to fix this problem? thanks friend
You're missing the dev files of tcl. Use
sudo apt-get install tcl-dev tk-dev
You need to install tcl development files.
You can find tcl-dev package for ubuntu 12.04 here https://launchpad.net/ubuntu/precise/+package/tcl-dev
Try this instead of make:
make MACHINE_TYPE=i686-m64 World
or
make NO_TCL=1 MACHINE_TYPE=i686-ubuntu World
In my case this lead me into another error
/usr/include/features.h:323:26: fatal error: bits/predefs.h: No such
file or directory
Which I found a fix here, such that:
sudo aptitude install libc6-dev-amd64