LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   downgrade gcc-version to compile mex-files for matlab??? (https://www.linuxquestions.org/questions/linux-newbie-8/downgrade-gcc-version-to-compile-mex-files-for-matlab-790832/)

margarita333 02-22-2010 12:54 PM

downgrade gcc-version to compile mex-files for matlab???
 
I am trying to run matlab 7.7 (R2008b) on my ubuntu 9.10 distribution..the thing is that I am totally new with both matlab and linux and I get the following error message from matlab when I try to run an example mex-function:

>> mex yprime.c

/home/margareta/Desktop/matlab/bin/mex: 1572: gcc: Permission denied

Warning: You are using gcc version "". The earliest gcc version supported
with mex is "4.0.0". The latest version tested for use with mex is "4.2.0".
To download a different version of gcc, visit http://gcc.gnu.org

eval: 1: gcc: Permission denied

mex: compile of ' "yprime.c"' failed.

??? Error using ==> mex at 213
Unable to complete successfully.

I had gcc-4.4 as default on my pc, so after this error I downloaded an older version (gcc-4.1) and removed with rm the symbolic link in /usr/bin pointing to gcc-4.4 and created a new one pointing to gcc-4.1. Now when I type gcc -v in the terminal it says that gcc is in the packages gcc and pentium-builder, suggesting to do an apt-get install. I tried that but than it says that gcc-4.1 is already the newest version.
Can anyone help me please? It seems that I have multiple versions of gcc installed but neither the terminal nor matlab can find them. What did I wrong? and HOW can I solve it???

irmin 02-22-2010 02:09 PM

Can you provide the output of 'ls -l /usr/bin/gcc*' and 'file /usr/bin/gcc*'?

knudfl 02-22-2010 02:36 PM

Default for Ubuntu 9.10 Karmic is gcc-4.4.1 .

You can have as many compilers (gcc, g++, etc. )
installed at the same time, as you want.

sudo apt-get install gcc-4.3 gcc-4.2 gcc-4.1
.. provides the compilers in the repo.

Suggest : use gcc-4.1 ( gcc-4.2 is version 4.2.4 ).
.....

margarita333 02-22-2010 03:33 PM

hey guys, thanks for helping me..ok the output is:

~$ ls -l /usr/bin/gcc*
lrwxrwxrwx 1 root root 16 2010-02-20 15:23 /usr/bin/gcc -> /usr/src/gcc-4.1
-rwxr-xr-x 1 root root 220484 2010-01-10 16:56 /usr/bin/gcc-4.4
-rwxr-xr-x 1 root root 16288 2009-08-27 14:03 /usr/bin/gccbug-4.1

I'm not sure what do you mean with file, I tried this:

~$ ls -l 'file /usr/bin/gcc*'
ls: cannot access file /usr/bin/gcc*: No such file or directory


~$ gcc -v
The program 'gcc' can be found in the following packages:
* gcc
* pentium-builder
Try: sudo apt-get install <selected package>
gcc: command not found


~$ sudo apt-get install gcc-4.1
[sudo] password for margareta:
Reading package lists... Done
Building dependency tree
Reading state information... Done
gcc-4.1 is already the newest version.
The following packages were automatically installed and are no longer required:
linux-headers-2.6.31-14 libgmp3-dev libgmpxx4ldbl libncurses5-dev
linux-headers-2.6.31-14-generic
Use 'apt-get autoremove' to remove them.
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.

As you can see, when I try to reinstall it says that I already have the newest version..any idea what's the problem?


smeezekitty 02-22-2010 03:39 PM

Code:

gcc-4.1 -v

irmin 02-22-2010 03:40 PM

Quote:

ls -l 'file /usr/bin/gcc*'
the correct command is without the quotes and the ls -l: file /usr/bin/gcc*
Are you sure that '/usr/src/gcc-4.1' is the correct target for gcc?

Post the output of 'file /usr/src/gcc*' too (without the quotes).

margarita333 02-23-2010 02:47 AM

hey irmin..

~$ file /usr/bin/gcc*
/usr/bin/gcc: symbolic link to `/usr/src/gcc-4.1'
/usr/bin/gcc-4.4: ELF 32-bit LSB executable, Intel 80386, version 1 (SYSV), dynamically linked (uses shared libs), for GNU/Linux 2.6.15, stripped
/usr/bin/gccbug-4.1: POSIX shell script text executable

~$ file /usr/src/gcc*
/usr/src/gcc-4.1: directory

Does that mean that the symbolic link should go inside the folder?

margarita333 02-23-2010 02:50 AM

I also tried the version option:

~$ gcc-4.1 -v
The program 'gcc-4.1' can be found in the following packages:
* hardening-wrapper
* gcc-4.1
Try: sudo apt-get install <selected package>
gcc-4.1: command not found

~$ sudo apt-get install gcc-4.1
[sudo] password for margareta:
Reading package lists... Done
Building dependency tree
Reading state information... Done
gcc-4.1 is already the newest version.
The following packages were automatically installed and are no longer required:
linux-headers-2.6.31-14 libgmp3-dev libgmpxx4ldbl libncurses5-dev
linux-headers-2.6.31-14-generic
Use 'apt-get autoremove' to remove them.
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.

So it isn't installed properly or the symbolic link is the problem?

knudfl 02-23-2010 08:24 AM

There is nothing in /usr/src/ , to be used as a compiler.
Files in /usr/src/ are most often source code only.


Suggest : 1) delete the alien link in /usr/bin ( = gcc )
2) Reinstall the required package(s) with "Synaptic".
Synaptic can reinstall packages.
"sudo apt-get install" cannot be used for reinstall.

The default is still "gcc" ( = gcc-4.4 ). Can also be installed.

Using e.g. gcc-4.1 , example : make CC=gcc-4.1
.....

Knowing which packages, you have installed : See "Synaptic".
Or use the command :
dpkg --get-selections \* > selections.txt
Or : dpkg --get-selections > selections.txt
.. which will save the text file selections.txt in /home/<user>/
.....

irmin 02-23-2010 10:11 AM

Quote:

Originally Posted by margarita333 (Post 3873538)
hey irmin..

~$ file /usr/bin/gcc*
/usr/bin/gcc: symbolic link to `/usr/src/gcc-4.1'
/usr/bin/gcc-4.4: ELF 32-bit LSB executable, Intel 80386, version 1 (SYSV), dynamically linked (uses shared libs), for GNU/Linux 2.6.15, stripped
/usr/bin/gccbug-4.1: POSIX shell script text executable

~$ file /usr/src/gcc*
/usr/src/gcc-4.1: directory

Does that mean that the symbolic link should go inside the folder?

The symbolic link should point to the gcc executable. Otherwise the link /usr/bin/gcc will act like the directory /usr/src/gcc-4.1, which is not what you want. Either you reinstall gcc-packages, as suggested by knudfl, or you change /usr/bin/gcc to point to the correct gcc executable.

Btw: Why does the link /usr/bin/gcc point to /usr/src? Did you try to compile gcc yourself? In this case you need to do a 'sudo make install' in the source folder too.

knudfl 02-23-2010 01:20 PM

# 10
Quote:

In this case you need to do a 'sudo make install'
in the source folder too.
I would not do that. May prevent a regularly installed
gcc from working :
All gcc-4.x are sharing the same libgcc**
And a new libgcc** may not work with any of those.

Better stick to the gcc selection in Synaptic.
.....


All times are GMT -5. The time now is 10:36 AM.