Installing GCC 4.4 on Fedora 14 to use CUDA SDK 4.0

In order to get CUDA SDK 4.0 to work on Fedora 14, I had to install an earlier version of GCC. This post is my notes on how I did that in the hope that if anyone else finds themselves needing to do something similar this will be of help. Apologies if I have posted it in the wrong place

Current versions of the CUDA SDK for Fedora require GCC v4.4 installed. However Fedora 14 ships with GCC 4.5 (my installation is running 4.5.4). This creates a problem if you try to install the CUDA SDK on F14 as CUDA will recognise that you are not using the specified version of GCC and will not permit you to compile any CUDA code. It returns an error message along the lines of:

To get around this, I downloaded and installed an earlier version of GCC. I didn’t want to lose the current install of the compiler, so this was an install to a non-default location with the intention being that I would switch backwards and forwards between the two installs as required. The steps I took were as follows:

  1. Using Google I did an RPM search for GCC 4.4.4 (I went for this specific version because that is the same as the install on another machine that I also run CUDA on). I downloaded the RPM and then tried to run it, using the –prefix tag. However this failed with the message that the rpm package is not relocatable

  2. I then went to to download the source files in order to build and install them myself. That website gives a lot of very good installation instructions which I won’t replicate here – I strongly advise anyone doing this that they read install guide on that site before trying an install themselves

  3. I downloaded gcc-4.4.4.tar.gz from a mirror (see for details) and unpacked it into the directory I had already created for it (here on called GCC4.4.4)

  4. Based on the installation instructions I then ran the following:

  1. I then got this error message:

This caused some confusion at first as I had already specified the –with-gmp and –with-mpfr options and was running GMP 4.3.1-7 and MPFR 2.4.2 however after some digging around I found this thread which told me I also needed to install the development packages to make the headers available. I installed the development packages using yum following which the configuration ran OK

  1. I then ran the makefile using no special options, this took over an hour to complete – so while it is running would be a good time to go for lunch

  2. On completion of that I then ran make install which completed sucessfully in less than 5 minutes.

  3. I then had a working install of GCC4.4.4. The only question which remained was how to get the CUDA compiler (NVCC) to recognise it. To do this I added the following to my .bashrc file:

  1. As I had added a suffix to my GCC4.4.4 install this meant that I could now invoke that compiler simply by typing “gcc-4.4.4” at the prompt instead of “gcc”. This isn’t quite sufficient for NVCC so the last step was to then go into the …/GCC4.4.4/gcc/bin directory and create a symbolic link called gcc to gcc-4.4.4

It’s worth noting that by doing this, I have effectively changed the compiler for any application on my box which uses the GCC compiler to version 4.4.4. The newer version 4.5.4 is still there and to switch back to it, all I need to do is comment out the line in .bashrc detailed in step 8 above. This is sufficient for my purposes but might not be good enough for everyone.

I suspect there may be an option in the CUDA install process to specify the location of the GCC compiler that you wish to use, but I didn’t bother figuring that out as this is good enough for me. It may also be possible to dynamically switch between different compiler versions, but I don’t know how that would be done – again it’s not something I need, but if anyone else figures out how to do these things and would like to share by all means please leave a reply.