Thread Subject: problem with Matlab 2009a on x64 Ubuntu intrepid

Subject: problem with Matlab 2009a on x64 Ubuntu intrepid

From: Amin

Date: 11 May, 2009 20:19:02

Message: 1 of 10

I have been using the latest version of matlab(2009a) on x64 ubuntu 8.10 for a couple of weeks now.
Every thing works fine but I can't make the matlab compile my C files into Matlab mex(using mex function). Intrepid is shipped with gcc 4.3.2 while the latest version that matlab supports is still gcc 4.2.3 so I think this should be the source of the problem.
When I mex a script, matlab warns me about the wrong version of the GCC and then the mex-ed file does not work properly. I get odd errors like "out of memory" or the mex ed function returns an incorrect value. The script works fine when I mex it on another computer with an older version of Linux(opensuse 10.3) which has a compatible GCC.

I tried to install an older version of GCC on intrepid but I either did it wrong or it didn't solve my problem.

I would appreciate if anyone have any idea/experience about solving this problem.

amin

Subject: problem with Matlab 2009a on x64 Ubuntu intrepid

From: Timothy

Date: 30 Jun, 2009 00:36:03

Message: 2 of 10

Hi Amin,

I have a similar problem too. I run R2009a on a Mac Intel machine and mex-ing my C code with mex wrappers seem to work fine. I also discovered MATLAB supports up to gcc 4.2. Apple's OS X still ships with gcc-4.1 so it worked fine. I tried compiling with mex on another x86 PC running Ubuntu 9.04 Jaunty (having install and changed the symbolic link of gcc to gcc-4.1 and also gcc-4.2 in two separate tests) and this is the verbose error message I get:

# mex -v vech.c
-> mexopts.sh sourced from directory (DIR = $HOME/.matlab/$REL_VERSION)
   FILE = /root/.matlab/R2009a/mexopts.sh
----------------------------------------------------------------
-> MATLAB = /usr/local/matlab/R2009a
-> CC = gcc
-> CC flags:
         CFLAGS = -ansi -D_GNU_SOURCE -fPIC -pthread -m32 -fexceptions -D_FILE_OFFSET_BITS=64
         CDEBUGFLAGS = -g
         COPTIMFLAGS = -O -DNDEBUG
         CLIBS = -Wl,-rpath-link,/usr/local/matlab/R2009a/bin/glnx86 -L/usr/local/matlab/R2009a/bin/glnx86 -lmx -lmex -lmat -lm -lstdc++
         arguments = -DMX_COMPAT_32
-> CXX = g++
-> CXX flags:
         CXXFLAGS = -ansi -D_GNU_SOURCE -D_FILE_OFFSET_BITS=64 -fPIC -pthread
         CXXDEBUGFLAGS = -g
         CXXOPTIMFLAGS = -O -DNDEBUG
         CXXLIBS = -Wl,-rpath-link,/usr/local/matlab/R2009a/bin/glnx86 -L/usr/local/matlab/R2009a/bin/glnx86 -lmx -lmex -lmat -lm
         arguments = -DMX_COMPAT_32
-> FC = g95
-> FC flags:
         FFLAGS = -fexceptions -fPIC
         FDEBUGFLAGS = -g
         FOPTIMFLAGS = -O
         FLIBS = -Wl,-rpath-link,/usr/local/matlab/R2009a/bin/glnx86 -L/usr/local/matlab/R2009a/bin/glnx86 -lmx -lmex -lmat -lm
         arguments = -DMX_COMPAT_32
-> LD = gcc
-> Link flags:
         LDFLAGS = -pthread -shared -m32 -Wl,--version-script,/usr/local/matlab/R2009a/extern/lib/glnx86/mexFunction.map -Wl,--no-undefined
         LDDEBUGFLAGS = -g
         LDOPTIMFLAGS = -O
         LDEXTENSION = .mexglx
         arguments =
-> LDCXX =
-> Link flags:
         LDCXXFLAGS =
         LDCXXDEBUGFLAGS =
         LDCXXOPTIMFLAGS =
         LDCXXEXTENSION =
         arguments =
----------------------------------------------------------------

-> gcc -c -I/usr/local/matlab/R2009a/extern/include -DMATLAB_MEX_FILE -ansi -D_GNU_SOURCE -fPIC -pthread -m32 -fexceptions -D_FILE_OFFSET_BITS=64 -DMX_COMPAT_32 -O -DNDEBUG "vech.c"

vech.c:77:2: warning: no newline at end of file
-> gcc -O -pthread -shared -m32 -Wl,--version-script,/usr/local/matlab/R2009a/extern/lib/glnx86/mexFunction.map -Wl,--no-undefined -o "vech.mexglx" vech.o -Wl,-rpath-link,/usr/local/matlab/R2009a/bin/glnx86 -L/usr/local/matlab/R2009a/bin/glnx86 -lmx -lmex -lmat -lm -lstdc++

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

    mex: link of ' "vech.mexglx"' failed.

Any luck with advice?

Cheers,
Tim

"Amin " <azandvak@aecom.yu.edu> wrote in message <gua17m$m72$1@fred.mathworks.com>...
> I have been using the latest version of matlab(2009a) on x64 ubuntu 8.10 for a couple of weeks now.
> Every thing works fine but I can't make the matlab compile my C files into Matlab mex(using mex function). Intrepid is shipped with gcc 4.3.2 while the latest version that matlab supports is still gcc 4.2.3 so I think this should be the source of the problem.
> When I mex a script, matlab warns me about the wrong version of the GCC and then the mex-ed file does not work properly. I get odd errors like "out of memory" or the mex ed function returns an incorrect value. The script works fine when I mex it on another computer with an older version of Linux(opensuse 10.3) which has a compatible GCC.
>
> I tried to install an older version of GCC on intrepid but I either did it wrong or it didn't solve my problem.
>
> I would appreciate if anyone have any idea/experience about solving this problem.
>
> amin

Subject: problem with Matlab 2009a on x64 Ubuntu intrepid

From: Christopher Hummersone

Date: 5 Nov, 2009 16:51:02

Message: 3 of 10

Hey,

I am having a similar problem. I'm running R2009a on Ubuntu 9.1 (karmic koala). Did you ever fix it? I also tried creating symbolic links, which stopped Matlab moaning about the GCC version, but they would compile and I got strange errors, that I didn't get using R2007a on a Mac running OS X 10.5 and Xcode.

Thanks,

Chris

Subject: problem with Matlab 2009a on x64 Ubuntu intrepid

From: Christopher Hummersone

Date: 5 Nov, 2009 16:58:03

Message: 4 of 10

Hey,

I am having a similar problem. I'm running R2009a on Ubuntu 9.1 (karmic koala). Did you ever fix it? I also tried creating symbolic links, which stopped Matlab moaning about the GCC version, but they would compile and I got strange errors, that I didn't get using R2007a on a Mac running OS X 10.5 and Xcode.

Thanks,

Chris

Subject: problem with Matlab 2009a on x64 Ubuntu intrepid

From: Christopher Hummersone

Date: 9 Nov, 2009 11:29:02

Message: 5 of 10

Well I've got pretty close: I installed gcc-4.2 etc and changed the symlinks in /usr/bin to point to them (as opposed to gcc-4.4 etc) and created a symlinks named 'glnxa64' pointing to 'glnx86' in the following directories:
$matlabroot/extern/lib
$matlabroot/bin

My main problem now seems to revolve around the 'ld' library in /usr/bin. Specifically I get the following error:

/usr/bin/ld: skipping incompatible $matlabroot/bin/glnxa64/libmx.so when searching for -lmx

which, due to the aforementioned symlink, is actually in
$matlabroot/bin/glnx86/libmx.so

So now I'm stumped! I guess it's some 32/64 bit incompatibility but I have no idea where to begin trying to fix it!

Chris

Subject: problem with Matlab 2009a on x64 Ubuntu intrepid

From: Christopher Hummersone

Date: 9 Nov, 2009 11:39:02

Message: 6 of 10

Oh and I also edited:

~/.matlab/R2009a/mexopts.sh

and commented out the line

CFLAGS='-ansi -D_GNU_SOURCE'

in the 'glnxa64' section, per this post:

http://forums.opensuse.org/programming-scripting/396126-gcc-matlab-opensuse-11-a.html#post1875821

Chris

Subject: problem with Matlab 2009a on x64 Ubuntu intrepid

From: Aman P.V. P.V

Date: 5 Dec, 2009 17:38:03

Message: 7 of 10

Hi,
       I also faced the same problem with matlab 2009a on x32 ubuntu 9.04. I resolved it installing gcc 4.2. you may need 4.3 also for other purposes. So you can use gcc alternatives and choose gcc 4.2 as the default version.
       I hope the following link will help you in doing that.
<http://www.infohit.net/blog/post/alternative-gcc-compilers-on-ubuntu-intrepid-and-jaunty.html>


"Amin " <azandvak@aecom.yu.edu> wrote in message <gua17m$m72$1@fred.mathworks.com>...
> I have been using the latest version of matlab(2009a) on x64 ubuntu 8.10 for a couple of weeks now.
> Every thing works fine but I can't make the matlab compile my C files into Matlab mex(using mex function). Intrepid is shipped with gcc 4.3.2 while the latest version that matlab supports is still gcc 4.2.3 so I think this should be the source of the problem.
> When I mex a script, matlab warns me about the wrong version of the GCC and then the mex-ed file does not work properly. I get odd errors like "out of memory" or the mex ed function returns an incorrect value. The script works fine when I mex it on another computer with an older version of Linux(opensuse 10.3) which has a compatible GCC.
>
> I tried to install an older version of GCC on intrepid but I either did it wrong or it didn't solve my problem.
>
> I would appreciate if anyone have any idea/experience about solving this problem.
>
> amin

Subject: problem with Matlab 2009a on x64 Ubuntu intrepid

From: Max

Date: 25 Jan, 2010 07:22:04

Message: 8 of 10

I faced the same problem with gcc compiler and here is the solution I found (neither of the above worked for me (at least, for c programs)).
I'm working on Mandriva 2010 - 64 bit, which comes with gcc4.4.1 and Matlab 2009b (64 bit), which requires gcc4.1 - 4.2. gcc-c++ is not installed.

First of all, back up the files you are going to change.

open mexopts.sh in ~/.matlab/R2009a/ and comment " CLIBS="$CLIBS -lstdc++" " in the section corresponding to your machine architecture (mine was glnxa64) ) (if gcc-c++ is installed on your machine, it might be not necessary, but other problems might arise)

At some point, I also changed CC variable (C compiler) to CC='gcc4.2' from CC='gcc', and it did work after that (or so it seems now), but it kept giving me a warning line: "UpperTriag.c:27:2: warning: no newline at end of file" (UpperTriag.c is the file I'm compiling) and I preferred another solution to the problem:

in the file "/matlab/bin/mex" (/matlab is the root directory for Matlab) I inserted LD="gcc4.2" right after LD="`eval echo $LD`" (which, of course, can be commented after that). Now Matlab gives it's standard warning:
"Warning: You are using gcc version "4.4.1". The earliest gcc version supported
         with mex is "4.1". The latest version tested for use with mex is "4.2".
         To download a different version of gcc, visit http://gcc.gnu.org "
but it doesn't reflect the reality anymore.

I tried to reconstruct all the steps I've done, and hope it works. Some changes I've made following the advices on this page could have stay, but it's highly unlikely.

Subject: problem with Matlab 2009a on x64 Ubuntu intrepid

From: ubuntu21 T

Date: 13 May, 2010 18:35:21

Message: 9 of 10

The following solution works well on my Ubuntu 10.04 x86 (32bit), tested on both Matlab R2010a and R2008b (the linux versions) + gcc-4.1

After installation, MATLAB worked out-of-the-box for me, except Simuink/"Embedded MATLAB Function", which I use a lot to run my simulations. I got all sort of errors and eventually came up with the following simple solution.

The problem, as mentioned throughout all this topic is that gcc-4.4 coming with Ubuntu 10.04 is unsupported by latest matlab version (R2010a). Ok, so let us simply install a version of gcc that is supported and make the proper link towards it:

Step1) one has to uncomment "multiverse" and "universe" repositories in /etc/apt/sources.list by removing the # sign before each repo, so that we may gain acces to some needed software (like gcc4.1):
$sudo vi /etc/apt/sources.list <- and there remove # before all "multiverse" and "universe" repos
$sudo apt-get update

Step2) Since apparently gcc4.2 is not offered by default (or at least at this date), no problem, just go for gcc4.1 which is highly robust to do the job:
$sudo apt-get install gcc-4.1 gcc-4.1-multilib libstdc++6-4.1-dev

Step3) The trick is that by actually installing gcc-4.1, the install procedure will not also change the default symbolic link from /usr/bin/gcc -> /usr/bin/gcc-4.4 , so we will have to do it manually:
$sudo cd /usr/bin/
$sudo ln -s gcc-4.1 gcc
And now just verify the link was properly done:
$sudo ls -la|grep gcc
And one should get something like this (copy-pasted from my console)
lrwxrwxrwx 1 root root 7 2010-05-09 14:59 gcc -> gcc-4.1

That's all. For me it works all very well.
Good luck.

Subject: problem with Matlab 2009a on x64 Ubuntu intrepid

From: Michael Thanou

Date: 20 Oct, 2010 13:09:04

Message: 10 of 10

"ubuntu21 T" <tcstefanro@gmail.com> wrote in message <hshgp9$kf3$1@fred.mathworks.com>...
> The following solution works well on my Ubuntu 10.04 x86 (32bit), tested on both Matlab R2010a and R2008b (the linux versions) + gcc-4.1
>
> After installation, MATLAB worked out-of-the-box for me, except Simuink/"Embedded MATLAB Function", which I use a lot to run my simulations. I got all sort of errors and eventually came up with the following simple solution.
>
> The problem, as mentioned throughout all this topic is that gcc-4.4 coming with Ubuntu 10.04 is unsupported by latest matlab version (R2010a). Ok, so let us simply install a version of gcc that is supported and make the proper link towards it:
>
> Step1) one has to uncomment "multiverse" and "universe" repositories in /etc/apt/sources.list by removing the # sign before each repo, so that we may gain acces to some needed software (like gcc4.1):
> $sudo vi /etc/apt/sources.list <- and there remove # before all "multiverse" and "universe" repos
> $sudo apt-get update
>
> Step2) Since apparently gcc4.2 is not offered by default (or at least at this date), no problem, just go for gcc4.1 which is highly robust to do the job:
> $sudo apt-get install gcc-4.1 gcc-4.1-multilib libstdc++6-4.1-dev
>
> Step3) The trick is that by actually installing gcc-4.1, the install procedure will not also change the default symbolic link from /usr/bin/gcc -> /usr/bin/gcc-4.4 , so we will have to do it manually:
> $sudo cd /usr/bin/
> $sudo ln -s gcc-4.1 gcc
> And now just verify the link was properly done:
> $sudo ls -la|grep gcc
> And one should get something like this (copy-pasted from my console)
> lrwxrwxrwx 1 root root 7 2010-05-09 14:59 gcc -> gcc-4.1
>
> That's all. For me it works all very well.
> Good luck.

      Since you have installed gcc4.1 with '$sudo apt-get install gcc-4.1 gcc-4.1-multilib libstdc++6-4.1-dev' I think it is better not to create the symbolic link for gcc-4.1 as that will make linux use gcc-4.1 instead of gcc-4.4. For example if you compile a file with gcc using the command 'gcc file.c' you will use gcc version 4.1 instead of 4.4.
      All we need to do is to configure Matlab to use gcc-4.1 instead of gcc (which is version 4.4). This can be done by editing the file <matlab_root>\bin\mexopts.sh. In this file you have to change the lines CC='gcc' to CC='gcc-4.1'. After that you will be able to compile mex-functions using gcc 4.1. These lines are also located in the files matopts.sh and mbuildopts.sh. You may also change these files in order to use other matlab commands like mcc.

      

Tags for this Thread

Everyone's Tags:

Add a New Tag:

Separated by commas
Ex.: root locus, bode

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Tag Activity for This Thread
Tag Applied By Date/Time
embedded matlab... ubuntu21 T 13 May, 2010 14:39:07
simulink ubuntu21 T 13 May, 2010 14:39:07
ubuntu 1004 ubuntu21 T 13 May, 2010 14:39:07
linux ubuntu21 T 13 May, 2010 14:39:07
2008b ubuntu21 T 13 May, 2010 14:39:07
2010a ubuntu21 T 13 May, 2010 14:39:07
matlab ubuntu21 T 13 May, 2010 14:39:07
gcc ubuntu21 T 13 May, 2010 14:39:07
mex gcc42 matla... Max 25 Jan, 2010 02:24:06
mex files Aman P.V 5 Dec, 2009 12:39:09
gcc supported v... Aman P.V 5 Dec, 2009 12:39:09
64 Christopher Hummersone 9 Nov, 2009 06:34:06
32 Christopher Hummersone 9 Nov, 2009 06:34:06
karmic Christopher Hummersone 9 Nov, 2009 06:34:06
linux Christopher Hummersone 9 Nov, 2009 06:34:05
91 Christopher Hummersone 5 Nov, 2009 11:54:07
gcc Christopher Hummersone 5 Nov, 2009 11:54:07
mex Christopher Hummersone 5 Nov, 2009 11:54:07
karmic koala Christopher Hummersone 5 Nov, 2009 11:54:07
ubuntu Christopher Hummersone 5 Nov, 2009 11:54:07
r2009a Christopher Hummersone 5 Nov, 2009 11:54:07
mex does not wo... Timothy 29 Jun, 2009 20:39:07
2009a Amin 11 May, 2009 16:24:06
x64 Amin 11 May, 2009 16:24:06
gcc Amin 11 May, 2009 16:24:06
mex Amin 11 May, 2009 16:24:06
ubuntu Amin 11 May, 2009 16:24:06
linux Amin 11 May, 2009 16:24:06
rssFeed for this Thread

Contact us at files@mathworks.com