From: Austriker Serrat on 23 Feb 2010 10:48 Hello, I am triyng to implement Matlab in a c++ program. http://www.cl.cam.ac.uk/~sjeh3/wii/ The application is using gtk a wii mote lib and the Matlab Camera Calibration Toolbox (http://www.vision.caltech.edu/bouguetj/calib_doc/). it works perfectly. I want to use matlab ploting tools to build a graphic provided by the application. But i am having issues building the app with matlab engine . Even with the examples like engdemo.cpp i always have this error : mex: link of ' "...mexa64"' failed. does somebody has an idea ? here are the console views: root(a)ubuntu:/home/hugo/Bureau/sjeh3-wii/wmgui# ./build2 ---------------------------------------------------------------- -> mbuildopts.sh sourced from directory (DIR = $HOME/.matlab/$REL_VERSION) FILE = /root/.matlab/R2009b/mbuildopts.sh ---------------------------------------------------------------- -> TMW_ROOT = /home/hugo/Matlab -> CC = g++-4.1 -> CC flags: CFLAGS = -ansi -D_GNU_SOURCE -I/home/hugo/Matlab/extern/include/cpp -I/home/hugo/Matlab/extern/include -DUNIX -DX11 -DGLNXA64 -DGCC -pthread CDEBUGFLAGS = -g COPTIMFLAGS = -O -DNDEBUG CLIBS = -Wl,-rpath-link,/home/hugo/Matlab/bin/glnxa64 -L/home/hugo/Matlab/runtime/glnxa64 -lmwmclmcrrt -lm arguments = -> LD = g++-4.1 -> Link flags: LDFLAGS = -pthread LDDEBUGFLAGS = -g LDOPTIMFLAGS = -O arguments = -L/usr/lib/ -L../toolbox -L../libcwiid -L../libcwiid -L/opt/gnome/lib64 -L/home/hugo/Matlab/bin/glnxa64 -L/home/hugo/Matlab/extern/include -L../../matlablibtest/toolbox ---------------------------------------------------------------- -> g++-4.1 -c -I/usr/include/cairo -I/usr/include/freetype2 -I/usr/include/libpng12 -I/opt/gnome/include/gtk-2.0 -I/usr/include/gtk-2.0 -I/usr/include/atk-1.0 -I/usr/include/pango-1.0 -I/usr/include/glib-2.0 -I/usr/lib/glib-2.0/include -I/usr/lib/gtk-2.0/include -I../libcwiid -I../toolbox -I/opt/matlab/extern/include -I/usr/lib -I/home/hugo/Matlab/extern/include -I/home/hugo/Matlab/bin/glnxa64 -ansi -D_GNU_SOURCE -I/home/hugo/Matlab/extern/include/cpp -I/home/hugo/Matlab/extern/include -DUNIX -DX11 -DGLNXA64 -DGCC -pthread -g "main.cpp" -> g++-4.1 -c -I/usr/include/cairo -I/usr/include/freetype2 -I/usr/include/libpng12 -I/opt/gnome/include/gtk-2.0 -I/usr/include/gtk-2.0 -I/usr/include/atk-1.0 -I/usr/include/pango-1.0 -I/usr/include/glib-2.0 -I/usr/lib/glib-2.0/include -I/usr/lib/gtk-2.0/include -I../libcwiid -I../toolbox -I/opt/matlab/extern/include -I/usr/lib -I/home/hugo/Matlab/extern/include -I/home/hugo/Matlab/bin/glnxa64 -ansi -D_GNU_SOURCE -I/home/hugo/Matlab/extern/include/cpp -I/home/hugo/Matlab/extern/include -DUNIX -DX11 -DGLNXA64 -DGCC -pthread -g "interface.cpp" -> g++-4.1 -c -I/usr/include/cairo -I/usr/include/freetype2 -I/usr/include/libpng12 -I/opt/gnome/include/gtk-2.0 -I/usr/include/gtk-2.0 -I/usr/include/atk-1.0 -I/usr/include/pango-1.0 -I/usr/include/glib-2.0 -I/usr/lib/glib-2.0/include -I/usr/lib/gtk-2.0/include -I../libcwiid -I../toolbox -I/opt/matlab/extern/include -I/usr/lib -I/home/hugo/Matlab/extern/include -I/home/hugo/Matlab/bin/glnxa64 -ansi -D_GNU_SOURCE -I/home/hugo/Matlab/extern/include/cpp -I/home/hugo/Matlab/extern/include -DUNIX -DX11 -DGLNXA64 -DGCC -pthread -g "support.cpp" -> g++-4.1 -g -pthread -L/usr/lib/ -L../toolbox -L../libcwiid -L../libcwiid -L/opt/gnome/lib64 -L/home/hugo/Matlab/bin/glnxa64 -L/home/hugo/Matlab/extern/include -L../../matlablibtest/toolbox -o wmgui main.o interface.o support.o -Wl,-rpath-link,/home/hugo/Matlab/bin/glnxa64 -L/home/hugo/Matlab/runtime/glnxa64 -lmwmclmcrrt -lm -lcalib -lgtk-x11-2.0 -lgdk-x11-2.0 -latk-1.0 -lgdk_pixbuf-2.0 -lpangocairo-1.0 -lpango-1.0 -lcairo -lgobject-2.0 -lgmodule-2.0 -ldl -lfreetype -lz -lfontconfig -lexpat -lglitz -lm -lpng12 -lXrender -lX11 -lpthread -lXau -lXdmcp -lgthread-2.0 -lglib-2.0 -lm -lcwiid main.o: In function `main': /home/hugo/Bureau/sjeh3-wii/wmgui/main.cpp:363: undefined reference to `engOpen' /home/hugo/Bureau/sjeh3-wii/wmgui/main.cpp:367: undefined reference to `engEvalString' collect2: ld returned 1 exit status mbuild: link of 'wmgui' failed. root(a)ubuntu:/home/hugo/Bureau/sjeh3-wii/wmgui# ./build2 -> mexopts.sh sourced from directory (DIR = $HOME/.matlab/$REL_VERSION) FILE = /root/.matlab/R2009b/mexopts.sh ---------------------------------------------------------------- -> MATLAB = /home/hugo/Matlab -> CC = gcc-4.1 -> CC flags: CFLAGS = -ansi -D_GNU_SOURCE -fexceptions -fPIC -fno-omit-frame-pointer -pthread CDEBUGFLAGS = -g COPTIMFLAGS = -O -DNDEBUG CLIBS = -Wl,-rpath-link,/home/hugo/Matlab/bin/glnxa64 -L/home/hugo/Matlab/bin/glnxa64 -lmx -lmex -lmat -lm -lstdc++ arguments = -DMX_COMPAT_32 -> CXX = g++-4.1 -> CXX flags: CXXFLAGS = -ansi -D_GNU_SOURCE -fPIC -fno-omit-frame-pointer -pthread CXXDEBUGFLAGS = -g CXXOPTIMFLAGS = -O -DNDEBUG CXXLIBS = -Wl,-rpath-link,/home/hugo/Matlab/bin/glnxa64 -L/home/hugo/Matlab/bin/glnxa64 -lmx -lmex -lmat -lm arguments = -DMX_COMPAT_32 -> FC = g95 -> FC flags: FFLAGS = -fexceptions -fPIC -fno-omit-frame-pointer FDEBUGFLAGS = -g FOPTIMFLAGS = -O FLIBS = -Wl,-rpath-link,/home/hugo/Matlab/bin/glnxa64 -L/home/hugo/Matlab/bin/glnxa64 -lmx -lmex -lmat -lm arguments = -DMX_COMPAT_32 -> LD = g++-4.1 -> Link flags: LDFLAGS = -pthread -shared -Wl,--version-script,/home/hugo/Matlab/extern/lib/glnxa64/mexFunction.map -Wl,--no-undefined LDDEBUGFLAGS = -g LDOPTIMFLAGS = -O LDEXTENSION = .mexa64 arguments = -lang cpp -L/usr/lib/ -L../toolbox -L../libcwiid -lcalib -L../libcwiid -L/opt/gnome/lib64 -lgtk-x11-2.0 -lgdk-x11-2.0 -latk-1.0 -lgdk_pixbuf-2.0 -lpangocairo-1.0 -lpango-1.0 -lcairo -lgobject-2.0 -lgmodule-2.0 -ldl -lfreetype -lz -lfontconfig -lexpat -lglitz -lm -lpng12 -lXrender -lX11 -lpthread -lXau -lXdmcp -lgthread-2.0 -lglib-2.0 -lm -lcwiid -L/home/hugo/Matlab/bin/glnxa64 -L/home/hugo/Matlab/extern/include -L../../matlablibtest/toolbox -> LDCXX = -> Link flags: LDCXXFLAGS = LDCXXDEBUGFLAGS = LDCXXOPTIMFLAGS = LDCXXEXTENSION = arguments = -lang cpp -L/usr/lib/ -L../toolbox -L../libcwiid -lcalib -L../libcwiid -L/opt/gnome/lib64 -lgtk-x11-2.0 -lgdk-x11-2.0 -latk-1.0 -lgdk_pixbuf-2.0 -lpangocairo-1.0 -lpango-1.0 -lcairo -lgobject-2.0 -lgmodule-2.0 -ldl -lfreetype -lz -lfontconfig -lexpat -lglitz -lm -lpng12 -lXrender -lX11 -lpthread -lXau -lXdmcp -lgthread-2.0 -lglib-2.0 -lm -lcwiid -L/home/hugo/Matlab/bin/glnxa64 -L/home/hugo/Matlab/extern/include -L../../matlablibtest/toolbox ---------------------------------------------------------------- -> g++-4.1 -c -I/usr/include/cairo -I/usr/include/freetype2 -I/usr/include/libpng12 -I/opt/gnome/include/gtk-2.0 -I/usr/include/gtk-2.0 -I/usr/include/atk-1.0 -I/usr/include/pango-1.0 -I/usr/include/glib-2.0 -I/usr/lib/glib-2.0/include -I/usr/lib/gtk-2.0/include -I../libcwiid -I../toolbox -I/opt/matlab/extern/include -I/usr/lib -I/home/hugo/Matlab/extern/include -I/home/hugo/Matlab/bin/glnxa64 -I/home/hugo/Matlab/extern/include -I/home/hugo/Matlab/simulink/include -DMATLAB_MEX_FILE -ansi -D_GNU_SOURCE -fPIC -fno-omit-frame-pointer -pthread -DMX_COMPAT_32 -g "main.cpp" -> g++-4.1 -c -I/usr/include/cairo -I/usr/include/freetype2 -I/usr/include/libpng12 -I/opt/gnome/include/gtk-2.0 -I/usr/include/gtk-2.0 -I/usr/include/atk-1.0 -I/usr/include/pango-1.0 -I/usr/include/glib-2.0 -I/usr/lib/glib-2.0/include -I/usr/lib/gtk-2.0/include -I../libcwiid -I../toolbox -I/opt/matlab/extern/include -I/usr/lib -I/home/hugo/Matlab/extern/include -I/home/hugo/Matlab/bin/glnxa64 -I/home/hugo/Matlab/extern/include -I/home/hugo/Matlab/simulink/include -DMATLAB_MEX_FILE -ansi -D_GNU_SOURCE -fPIC -fno-omit-frame-pointer -pthread -DMX_COMPAT_32 -g "interface.cpp" -> g++-4.1 -c -I/usr/include/cairo -I/usr/include/freetype2 -I/usr/include/libpng12 -I/opt/gnome/include/gtk-2.0 -I/usr/include/gtk-2.0 -I/usr/include/atk-1.0 -I/usr/include/pango-1.0 -I/usr/include/glib-2.0 -I/usr/lib/glib-2.0/include -I/usr/lib/gtk-2.0/include -I../libcwiid -I../toolbox -I/opt/matlab/extern/include -I/usr/lib -I/home/hugo/Matlab/extern/include -I/home/hugo/Matlab/bin/glnxa64 -I/home/hugo/Matlab/extern/include -I/home/hugo/Matlab/simulink/include -DMATLAB_MEX_FILE -ansi -D_GNU_SOURCE -fPIC -fno-omit-frame-pointer -pthread -DMX_COMPAT_32 -g "support.cpp" -> g++-4.1 -g -pthread -shared -Wl,--version-script,/home/hugo/Matlab/extern/lib/glnxa64/mexFunction.map -Wl,--no-undefined -o "wmgui.mexa64" main.o interface.o support.o -lang cpp -L/usr/lib/ -L../toolbox -L../libcwiid -lcalib -L../libcwiid -L/opt/gnome/lib64 -lgtk-x11-2.0 -lgdk-x11-2.0 -latk-1.0 -lgdk_pixbuf-2.0 -lpangocairo-1.0 -lpango-1.0 -lcairo -lgobject-2.0 -lgmodule-2.0 -ldl -lfreetype -lz -lfontconfig -lexpat -lglitz -lm -lpng12 -lXrender -lX11 -lpthread -lXau -lXdmcp -lgthread-2.0 -lglib-2.0 -lm -lcwiid -L/home/hugo/Matlab/bin/glnxa64 -L/home/hugo/Matlab/extern/include -L../../matlablibtest/toolbox -Wl,-rpath-link,/home/hugo/Matlab/bin/glnxa64 -L/home/hugo/Matlab/bin/glnxa64 -lmx -lmex -lmat -lm g++-4.1: cpp: Aucun fichier ou dossier de ce type mex: link of ' "wmgui.mexa64"' failed. #!/bin/sh (mex or mbuild) -v -g -output wmgui main.cpp interface.cpp support.cpp -lang cpp \ -L/usr/lib/ -L../toolbox -L../libcwiid -lcalib -L../libcwiid -L/opt/gnome/lib64 -lgtk-x11-2.0 -lgdk-x11-2.0 -latk-1.0 -lgdk_pixbuf-2.0 -lpangocairo-1.0 -lpango-1.0 -lcairo -lgobject-2.0 -lgmodule-2.0 -ldl -lfreetype -lz -lfontconfig -lexpat -lglitz -lm -lpng12 -lXrender -lX11 -lpthread -lXau -lXdmcp -lgthread-2.0 -lglib-2.0 -lm -lcwiid -L/home/hugo/Matlab/bin/glnxa64 -L/home/hugo/Matlab/extern/include -L../../matlablibtest/toolbox \ -I/usr/include/cairo -I/usr/include/freetype2 -I/usr/include/libpng12 -I/opt/gnome/include/gtk-2.0 -I/usr/include/gtk-2.0 -I/usr/include/atk-1.0 -I/usr/include/pango-1.0 -I/usr/include/glib-2.0 -I/usr/lib/glib-2.0/include -I/usr/lib/gtk-2.0/include -I../libcwiid -I../toolbox -I/opt/matlab/extern/include -I/usr/lib -I/home/hugo/Matlab/extern/include -I/home/hugo/Matlab/bin/glnxa64 Sincerely, Hugo
From: Hugo Serrat on 23 Feb 2010 12:08 I forgot to say that i wanted to use Matlab engine and not my c++ application in matlab. maybe it wasn't so clear. I don't think the program will work as a mex-file. for the main script modification i just added engine.h and an extract from engdemo.c in the main function. Sincerely hugo
From: Hugo Serrat on 24 Feb 2010 05:25 I searched on the net but there isn't any useful link. the same questions where asked on the central newsgroup but there isn't any answer. so i tried to do this maybe it will give an idea to somebody : root(a)ubuntu:/home/hugo/Bureau# mex -v -g engdemo.c -> mexopts.sh sourced from directory (DIR = $HOME/.matlab/$REL_VERSION) FILE = /root/.matlab/R2009b/mexopts.sh ----------------------------------------------------------------/Matlab/bin/glnxa64 -L/home/hugo/Matlab-> MATLAB = /home/hugo/Matlab -> CC = gcc-4.1b/extern/include -I/home/hugo/Matlab/bin/glnxa64 -L/home/hugo/Ma-> CC flags: CFLAGS = -ansi -D_GNU_SOURCE -fexceptions -fPIC -fno-omit-frame-pointer -pthread CDEBUGFLAGS = -g COPTIMFLAGS = -O -DNDEBUGlab/extern/include -I/home/hugo/Matlab/bin/glnxa64 -L/ CLIBS = -Wl,-rpath-link,/home/hugo/Matlab/bin/glnxa64 -L/home/hugo/Matlab/bin/glnxa64 -lmx -lmex -lmat -lm -lstdc++ arguments = -DMX_COMPAT_32 -> CXX = g++-4.1 -> CXX flags: CXXFLAGS = -ansi -D_GNU_SOURCE -fPIC -fno-omit-frame-pointer -pthread CXXDEBUGFLAGS = -g CXXOPTIMFLAGS = -O -DNDEBUG CXXLIBS = -Wl,-rpath-link,/home/hugo/Matlab/bin/glnxa64 -L/home/hugo/Matlab/bin/glnxa64 -lmx -lmex -lmat -lm arguments = -DMX_COMPAT_32 -> FC = g95 -> FC flags: FFLAGS = -fexceptions -fPIC -fno-omit-frame-pointer FDEBUGFLAGS = -g FOPTIMFLAGS = -O FLIBS = -Wl,-rpath-link,/home/hugo/Matlab/bin/glnxa64 -L/home/hugo/Matlab/bin/glnxa64 -lmx -lmex -lmat -lm arguments = -DMX_COMPAT_32 -> LD = gcc-4.1 -> Link flags: LDFLAGS = -pthread -shared -Wl,--version-script,/home/hugo/Matlab/extern/lib/glnxa64/mexFunction.map -Wl,--no-undefined LDDEBUGFLAGS = -g LDOPTIMFLAGS = -O LDEXTENSION = .mexa64 arguments = -> LDCXX = -> Link flags: LDCXXFLAGS = LDCXXDEBUGFLAGS = LDCXXOPTIMFLAGS = LDCXXEXTENSION = arguments = ---------------------------------------------------------------- -> gcc-4.1 -c -I/home/hugo/Matlab/extern/include -I/home/hugo/Matlab/simulink/include -DMATLAB_MEX_FILE -ansi -D_GNU_SOURCE -fexceptions -fPIC -fno-omit-frame-pointer -pthread -DMX_COMPAT_32 -g "engdemo.c" -> gcc-4.1 -g -pthread -shared -Wl,--version-script,/home/hugo/Matlab/extern/lib/glnxa64/mexFunction.map -Wl,--no-undefined -o "engdemo.mexa64" engdemo.o -Wl,-rpath-link,/home/hugo/Matlab/bin/glnxa64 -L/home/hugo/Matlab/bin/glnxa64 -lmx -lmex -lmat -lm -lstdc++ engdemo.o: In function `main': /home/hugo/Bureau/engdemo.c:35: undefined reference to `engOpen' /home/hugo/Bureau/engdemo.c:55: undefined reference to `engPutVariable' /home/hugo/Bureau/engdemo.c:61: undefined reference to `engEvalString' /home/hugo/Bureau/engdemo.c:66: undefined reference to `engEvalString' /home/hugo/Bureau/engdemo.c:67: undefined reference to `engEvalString' /home/hugo/Bureau/engdemo.c:68: undefined reference to `engEvalString' /home/hugo/Bureau/engdemo.c:69: undefined reference to `engEvalString' engdemo.o:/home/hugo/Bureau/engdemo.c:82: more undefined references to `engEvalString' follow engdemo.o: In function `main': /home/hugo/Bureau/engdemo.c:101: undefined reference to `engOutputBuffer' /home/hugo/Bureau/engdemo.c:118: undefined reference to `engEvalString' /home/hugo/Bureau/engdemo.c:130: undefined reference to `engGetVariable' /home/hugo/Bureau/engdemo.c:142: undefined reference to `engClose' collect2: ld returned 1 exit status mex: link of ' "engdemo.mexa64"' failed. root(a)ubuntu:/home/hugo/Bureau# gcc -V 4.1 -B/home/hugo/Matlab/extern/include -I/home/hugo/Matlab/extern/include -o engdemo2 engdemo2.c -B/home/hugo/Matlab/bin/glnxa64 -leng -lmx -lut /usr/bin/ld: warning: libmat.so, needed by /home/hugo/Matlab/bin/glnxa64/libeng.so, not found (try using -rpath or -rpath-link) /usr/bin/ld: warning: libmwfl.so, needed by /home/hugo/Matlab/bin/glnxa64/libmx.so, not found (try using -rpath or -rpath-link) /home/hugo/Matlab/bin/glnxa64/libeng.so: undefined reference to `matCreateMATFile' /home/hugo/Matlab/bin/glnxa64/libeng.so: undefined reference to `matGetNextVariable' /home/hugo/Matlab/bin/glnxa64/libeng.so: undefined reference to `matClose' /home/hugo/Matlab/bin/glnxa64/libmx.so: undefined reference to `fl::mem::manager::instance()' /home/hugo/Matlab/bin/glnxa64/libmx.so: undefined reference to `fl::app::init::init()' /home/hugo/Matlab/bin/glnxa64/libmx.so: undefined reference to `fl::app::init::~init()' /home/hugo/Matlab/bin/glnxa64/libmx.so: undefined reference to `fl::mem::aligned_heap::instance' /home/hugo/Matlab/bin/glnxa64/libmx.so: undefined reference to `fl::mem::create_managed_pool(unsigned long, unsigned long)' /home/hugo/Matlab/bin/glnxa64/libeng.so: undefined reference to `matPutNextVariable' collect2: ld returned 1 exit status sincerely Hugo
From: James Tursa on 24 Feb 2010 11:13 "Hugo Serrat" <removethis.hu.serrat(a)gmail.com.removethis> wrote in message <hm2uqh$q4e$1(a)fred.mathworks.com>... > I searched on the net but there isn't any useful link. the same questions where asked on the central newsgroup but there isn't any answer. so i tried to do this maybe it will give an idea to somebody : > > root(a)ubuntu:/home/hugo/Bureau# mex -v -g engdemo.c That is not the way to compile an engine application. For an engine application you need to use a specific options file with the mex command. e.g., for WinXP it would be something like this for the supplied lcc compiler: options = [matlabroot '\bin\win32\mexopts\lccengmatopts.bat'] mex('-f',options,'engdemo.c') Then to run it you can use the bang operator: !engdemo I would expect something similar for your system. You need to find and use the appropriate ___engmatopts.bat (or similar) file for your selected compiler. James Tursa
From: Hugo Serrat on 25 Feb 2010 08:19 "James Tursa" <aclassyguy_with_a_k_not_a_c(a)hotmail.com> wrote in message <hm3j6e$9du$1(a)fred.mathworks.com>... > "Hugo Serrat" <removethis.hu.serrat(a)gmail.com.removethis> wrote in message <hm2uqh$q4e$1(a)fred.mathworks.com>... > > I searched on the net but there isn't any useful link. the same questions where asked on the central newsgroup but there isn't any answer. so i tried to do this maybe it will give an idea to somebody : > > > > root(a)ubuntu:/home/hugo/Bureau# mex -v -g engdemo.c > > That is not the way to compile an engine application. For an engine application you need to use a specific options file with the mex command. e.g., for WinXP it would be something like this for the supplied lcc compiler: > > options = [matlabroot '\bin\win32\mexopts\lccengmatopts.bat'] > mex('-f',options,'engdemo.c') > > Then to run it you can use the bang operator: > > !engdemo > > I would expect something similar for your system. You need to find and use the appropriate ___engmatopts.bat (or similar) file for your selected compiler. > > James Tursa Thank you it worked perfectly. but what a stupid mistake ! I had an error : Can't start matlab Engine. Just forgot to install csh. After that everything worked perfectly. Hugo Serrat
|
Pages: 1 Prev: access data from whole cell array Next: Using the 'coneplot' function |