1) I need gcc-4.1 for Matlab mex usage, but I can't get it installed fully with apt-get install:

The following packages have unmet dependencies:
libstdc++6-4.1-dev : Depends: gcc-4.1-base (= 4.1.2-27ubuntu1) but 4.1.2-29ubuntu1 is     to be installed
Depends: g++-4.1 (= 4.1.2-27ubuntu1) but it is not going to be installed
E: Broken packages

2) I now only have gcc-4.1-base and -multilib installed. When compiling mex file:

/usr/bin/ld: cannot find -lstdc++
collect2: ld returned 1 exit status

Something is wrong with libstdc++6-4.1-dev. So I went to http://packages.ubuntu.com/maverick/gcc-4.1 and download libstdc++6-4.1-dev_4.1.2-27ubuntu1_i386.deb. But cannot install it:

Dependency is not satisfiable: g++-4.1 (= 4.1.2-21ubuntu1)



After a bunch of searching to get gcc-4.1 & g++-4.1 in Ubuntu 10.10 (maverick), I found easy work around.

Add to the end of /etc/apt/sources.list source from 10.04 (lucid)

deb http://mirrors.us.kernel.org/ubuntu/ lucid main universe

Then run

sudo apt-get update

You have to specify version 4.1.2-27, as libstdc++6-4.1-dev has not been back ported to 4.1.2-29.

sudo apt-get install gcc-4.1=4.1.2-27ubuntu1 gcc-4.1-base=4.1.2-27ubuntu1 cpp-4.1=4.1.2-27ubuntu1 g++-4.1

Ubuntu strives to avoid the old "dependency hell" by assuring that distributions are self-consistent in their libraries. By using commercial software (Matlab) that is a few years behind, you've got a MEX system that is not ready for Maverick.

As aking1012 suggested, you have to do some significant rolling back of versions. It could probably be said that you can't have the cake of Ubuntu convenience and eat the old-style MEX stuff too (or not without mucking about quite a bit).


Not sure if it will function properly if you override the dependencies and roll your own deb, but it's worth a shot.

apt-get build-dep deb-name-here  
apt-get source deb-name-here  
cd package-dir/deb  
nano control 

and change the dependency to a > instead of an =

cd ..  

It might work...

Another option is to use update alternatives to roll-back your versions(safer)
yet another option is to modify version number in the dependency required by the build
two of the three can break your package management though.

The last and best option is to compile from source in ~/src and install to /opt for the versions you need and tell the installer to look there for dependencies


libstdc++6-4.1-dev is not available in Maverick - it was last available in Lucid

You can install a later version of GCC. You will get a warning message but the MEX will still compile.

If you get MATLAB R2010b you can roll with GCC 4.3

There are instructions regarding this at: https://help.ubuntu.com/community/MATLAB#MEX%20functions

Your Answer

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