LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 03-02-2011, 05:24 AM   #1
Reicher
LQ Newbie
 
Registered: Mar 2011
Posts: 2

Rep: Reputation: 0
Creating mex-files with gcc with external libraries (matlab)


Hi, I have been browsing trough forums, manuals and people for a few days now wihout success so I thought i give this a go, any help will be very appricieted!

I'm using Matlab 2010a in Ubuntu 10.10. I also have a AVT Marlin F033C firewire camera and want to use the two together. Since most things i will do with the images will be processed in matlab I decided that the best would be if i could do everything in matlab.

The code for capturing a picture is however in c and uses the library dc1394 (usr/lib). Compiling this with gcc works good:
$ gcc grab_gray_image.c -ldc1394

To be able to create a mex-file of it (that matlab can run) I have included "mex.h" in the headers and added the function mexFunction in the very top, this function should do more once it works...:
#include "mex.h"

void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[])
{
mexErrMsgTxt("STUFFNTHINGS");
}

In matlab, after doing the:
>> mex -setup
Choosing "Template Options file for building gcc MEX-files".

When trying to compile i get a few errors but these are easily removed by taking away all the //-comments and all the inline for a few functions (this should do anything for the functionality right?).
After that I am still stuck with this error:

>> mex grab_gray_image.c -ldc1394
/usr/bin/ld: cannot find -lstdc++
collect2: ld returned 1 exit status

mex: link of ' "grab_gray_image.mexa64"' failed.

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


I should probably also note that I needed to rollback to gcc 4.1 since that is the latest one matlab 2010a can handle and now don't get that warning anymore.

So, anyone have any idea? I don't even know what this stdc++ is for really=/
 
Old 03-02-2011, 06:31 AM   #2
knudfl
LQ 5k Club
 
Registered: Jan 2008
Location: Copenhagen DK
Distribution: PCLinuxOS2019 CentOS6.10 CentOS7.7 + 50+ other Linux OS, for test only.
Posts: 17,316

Rep: Reputation: 3578Reputation: 3578Reputation: 3578Reputation: 3578Reputation: 3578Reputation: 3578Reputation: 3578Reputation: 3578Reputation: 3578Reputation: 3578Reputation: 3578
Welcome to LQ.

Quote:
I don't even know what this stdc++ is for really
lstdc++ = libstdc++ >> libstdc++.so
'libstdc++' is the c++ library included in gcc / g++.

sudo apt-get install g++ :
Will install the libstdc++6<.x.x>-dev for your version of Ubuntu.
Providing like : /usr/lib/gcc/i686-linux-gnu/4.4/libstdc++.so
( It may already be installed.)

Just point to it. (Or make a (temporary) link to /usr/lib/).

..

Last edited by knudfl; 03-02-2011 at 06:36 AM.
 
Old 03-02-2011, 08:23 AM   #3
Reicher
LQ Newbie
 
Registered: Mar 2011
Posts: 2

Original Poster
Rep: Reputation: 0
Quote:
Originally Posted by knudfl View Post
Welcome to LQ.



lstdc++ = libstdc++ >> libstdc++.so
'libstdc++' is the c++ library included in gcc / g++.

sudo apt-get install g++ :
Will install the libstdc++6<.x.x>-dev for your version of Ubuntu.
Providing like : /usr/lib/gcc/i686-linux-gnu/4.4/libstdc++.so
( It may already be installed.)

Just point to it. (Or make a (temporary) link to /usr/lib/).

..
After some more playing around with libstdc++ and pointing to diffrent versions of this library it worked with:
mex grab_gray_image.c -ldc1394 -L"/usr/lib/gcc/x86_64-linux-gnu/4.4"

Thank you very much!
 
Old 03-14-2011, 04:58 PM   #4
Evil85
LQ Newbie
 
Registered: Mar 2011
Posts: 2

Rep: Reputation: 0
Quote:
Originally Posted by Reicher View Post
After some more playing around with libstdc++ and pointing to diffrent versions of this library it worked with:
mex grab_gray_image.c -ldc1394 -L"/usr/lib/gcc/x86_64-linux-gnu/4.4"

Thank you very much!
did you have any linking problem ?

Because I use Ubuntu 10.10 and Matlab 2010a with gcc 4.4 and eclipse I see now that it's very newer.
Matlab 2010a support 4.2.3 but I cant it in repositories
And I have a big linking error :

/usr/bin/ld: warning: libicudata.so.40, needed by /home/evil/Matlab2010a/bin/glnxa64/libmx.so, not found (try using -rpath or -rpath-link)
/usr/bin/ld: warning: libicuuc.so.40, needed by /home/evil/Matlab2010a/bin/glnxa64/libmx.so, not found (try using -rpath or -rpath-link)
/usr/bin/ld: warning: libicui18n.so.40, needed by /home/evil/Matlab2010a/bin/glnxa64/libmx.so, not found (try using -rpath or -rpath-link)
/usr/bin/ld: warning: libicuio.so.40, needed by /home/evil/Matlab2010a/bin/glnxa64/libmx.so, not found (try using -rpath or -rpath-link)

.....
 
Old 03-14-2011, 05:37 PM   #5
knudfl
LQ 5k Club
 
Registered: Jan 2008
Location: Copenhagen DK
Distribution: PCLinuxOS2019 CentOS6.10 CentOS7.7 + 50+ other Linux OS, for test only.
Posts: 17,316

Rep: Reputation: 3578Reputation: 3578Reputation: 3578Reputation: 3578Reputation: 3578Reputation: 3578Reputation: 3578Reputation: 3578Reputation: 3578Reputation: 3578Reputation: 3578
Evil85, post # 4 : Welcome to LQ. .. Ubuntu 10.10 Maverick 64bits :

Adding 'karmic' to /etc/apt/sources.list will make it possible to do :

sudo apt-get update && sudo apt-get install gcc-4.2 libicu40
( You can have as many compilers installed at the same time, as you want.)
'gcc-4.2', 'g++-4.2', libicu40 will install with no problems.
Code:
deb http://76.73.4.58/ubuntu/ karmic main
deb http://76.73.4.58/ubuntu/ karmic universe
deb http://security.ubuntu.com/ubuntu karmic-security main
deb http://security.ubuntu.com/ubuntu karmic-security universe
EDIT : gcc should probably be gcc-4.1 ?

..

Last edited by knudfl; 03-18-2011 at 08:26 PM.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
downgrade gcc-version to compile mex-files for matlab??? margarita333 Linux - Newbie 10 02-23-2010 02:20 PM
Error compiling mex files for matlab using make. zest n zeal Linux - Newbie 1 01-30-2009 02:50 PM
Creating a link for Matlab jjones88 Linux - Software 2 06-16-2008 05:43 PM
gcc: libraries for copying files, ftp, data output ? frenchn00b Programming 2 08-29-2007 02:26 PM
creating a system files on an external drive zaza Linux - Newbie 2 05-03-2002 05:07 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

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

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration