3

After some pains I was finally able to build me a gcc 4.9.3 (I don't have root on the machine I'm working on, and Fedora 22 doesn't package gcc 4.9 anyway). And it even works, i.e. using it to compile simple programs results in executables which do their job.

However... what happens when I want to use it with packages that have autotools configure scripts, or CMake? I probably need to set some environment variables to let them know they should prefer the new compiler - and its associated include & library files. I guess I can set

export CC=$HOME/opt/gcc/bin/gcc
export CXX=$HOME/opt/gcc/bin/g++

but I'm sure there are a few other environment variables settings to make. What are they?

  • What means "I don't have root on my distro"? And if you're not cross compiling, you can just set your PATH to where you'd installed your new gcc: export PATH=$HOME/opt/gcc/bin:$PATH. – user140866 Dec 9 '15 at 13:14
  • And compiler must pickup it's own compiler-related and system related include files automatically. If you build and install libs somewhere that install their own header files, you need to add them separately as -I/path/to/include command line options when building programs that depend on them. And do not forget about -L/path/to/lib where actual library files are installed. – user140866 Dec 9 '15 at 13:16
  • @siblynx: 1. I don't have root on my machine. 2. I can certainly set -I and -L when manually building things, but I need autoconf, cmake etc. to do this on their own, based on the environment variables I hand to them. – einpoklum Dec 9 '15 at 13:18
  • For autotools, adding CFLAGS=-I/path/to/include LDFLAGS=-L/path/to/lib (CXXFLAGS for g++) to configure command line is usually sufficient. Add compiler to your PATH as I described before. CMake is overcomplicated thing, I don't remember exact details for it, but I've seen some related things when I'd run ccmake . after configuring. – user140866 Dec 9 '15 at 13:21
  • And why you have no root on your machine? It means you're not sitting under root account, or intentionally disabled root access including login/sudo? – user140866 Dec 9 '15 at 13:29

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.