How to get CUDA 5 working in OpenSUSE 12.2

When you try to install CUDA Toolkit 5 in OpenSUSE 12.2 you will get an error saying that gcc 4.7 is not supported.

Unsupported compiler: 4.7.1

The solution is to install gcc 4.6, either to compile it ourselves, or to install a binary from http://software.opensuse.org/search. Don't forget the -devel package. You don't have to compile the driver, there is an rpm package in YAST or zypper named nvidia-computeG02.

To install the CUDA 5.0 Toolkit place a symlink to gcc and g++ from GCC 4.6 in a place with higher priority in your $PATH than the default ones. Then you can run the installer without error. After that move the symlinks to directory /usr/local/cuda-5.0/bin. Adjust the environment variables as suggested by the installer. Best by placing a shell script to /etc/profile.d and placing a .conf file to /etc/ld.so.conf.d and running ldconfig. After new login you should be able to run nvcc and compile the sample programs.