gcc, matlab and opensuse 11

Hi everyone,

I am a Linux newbie and I was wondering if somebody would be kind enough to help me out with some questions regarding setting up gcc.

I’m running the x86_64 version of openSUSE 11 on one of the computers at my research lab and we are also running Matlab 2008a. We have some MEX C++ code for which we need a version of gcc between 4.0.0 and 4.2.0. (I was able to set up a later, precompiled version of gcc (4.3.1 I think) from one of the openSUSE 11 repositories, but when I ran the compiled mex code Matlab just exited without any error message.)

My two questions are:

  1. I noticed that a repository for an earlier version of openSUSE (10.2) has an earlier precompiled version of gcc which would potentially work with Matlab (4.1.3 I think). Would it be safe to download it with YaST and attempt to set it up on openSUSE 11.0?

  2. If not, does anybody have detailed instructions for setting up an earlier version of gcc (with the C++ extension) with a newer version already on the PC? (I’ve tried looking at the documentation on gcc.gnu.org but it was highly confusing.)

I know this is a lot to ask - I greatly appreciate any help you can provide.

Thank you for your time,


  1. no don’t do this, all software in opensuse 11.0 is compiled with the new gcc version and installing an old one, which will cause that the new version gets removed, could break the whole system.

  2. yes this is possible, have a look at GCC Frequently Asked Questions - GNU Project - Free Software Foundation (FSF) guess you have to recompile the older gcc version for this, but this is the recommended way.

hope this helps

Thanks Monex. I’ve got another question - I found this repository:

Index of /repositories/devel:/tools:/gcc/openSUSE_11.0/x86_64

which seems to have a precompiled version of gcc 4.1
(the filename is http://download.opensuse.org/repositories/devel:/tools:/gcc/openSUSE_11.0/x86_64/gcc41-4.1.3_20080612-3.16.x86_64.rpm). Would this work?



You not need chage the gcc version I am using the same matlab and the same version of opensuse 11 (x86_64). In order to use the mex with the last gcc you need make a link $/MATLAB/sys/os/glnxa64/libstdc++.so.6 to /usr/lib64/libstdc++.so.6 and $/MATLAB/sys/os/glnxa64/libgcc_s.so.1 to /lib64/libgcc_s.so.1 (remove or change the name to the original links or files) and you need to modify the file $Home/.matlab/R2008a/mexopts.sh comment out the line:


This line is inside glnxa64) section.

I did this and mex work without problems…



yes these should work because these rpms are not replacing the original gcc packages. Maybe you have to set the compiler variables (CC and LD_LIBRARY_PATH) so that the correct compiler and the corresponding libraries are used.

But maybe you want to try the suggestion from jdiazgon first. If this works for you this is then the better solution :slight_smile:

jdiazgon: Thanks for the suggestion. I tried it out and it didn’t work, although I think I may have been setting the links incorrectly - I’ll try it out again tonight.

Monex: I tried installing the gcc 4.1 RPM (first removing some of the gcc 4.3 files) and it didn’t have an effect (when I compiled the mex file in Matlab it didn’t recognize the version of the older gcc). I then took off gcc 4.1 put gcc 4.3 back on later and Matlab recognized 4.3 again. I think this may have been because of the compiler variables you mention - how do you change the compiler variables? (And are there any other system variables that should be changed, and if so how?)

I also tried compiling an older version of gcc (4.2) with a suffix (so it was installed in /opt/gcc42). I think the compile was successful - I tried running the testsuite and it didn’t seem to find any problems. Is there a way to now switch the active version of gcc to the one I’ve installed?

I’m sorry for innundating you with questions - I greatly appreciate your help.



normally the standard compiler will be used and this is gcc4.3 on opensuse 11. If you want to use the new installed gcc you have to set some environment variables before you run configure (don’t do something else or remove files). First set the environment variables properly:

export CC=</opt/gcc/bin/gcc-xxx>
export CXX=</opt/gcc/bin/g++-xxx>

That will cause that now the specified commandos will be used instead of standard gcc and g++. Edit your ~/.bashrc and add

export LD_LIBRARY_PATH=/opt/gcc/lib:$LD_LIBRARY_PATH

This causes that you can run the program after it is compiled and linked. This is necessary because otherwise it won’t find the linked libs which are now in a different location.

Then run configure (or what ever commando is used to prepare compilation) and look out that now the other compiler is used.

If you are using the gcc versions from the build service, you have to adjust the paths to /usr/bin/gcc-xxx and so on. I don’t think that you have to adjust the LD_LIBRARY variable then because alls libs are installed to the default destination (as far as I know :wink: ).

hope i didn’t miss a thing :slight_smile: