2018/12/7
- 启动时
failed-to-load-module-canberra-gtk-module
解决:
sudo apt-get install libcanberra-gtk-module
*如果已安装可以:
sudo apt-get install libcanberra-gtk-module:i386
>> mex ~/t/RenderMex.cpp
Building with 'g++'.
Warning: You are using gcc version '7.3.0'. The version of gcc is not
supported. The version currently supported with MEX is '4.9.x'. For a list
of currently supported compilers see:
http://www.mathworks.com/support/compilers/current_release.
Error using mex
/home/quwanxin/t/RenderMex.cpp:4:10: fatal error: GL/osmesa.h: No such file
or directory
#include <GL/osmesa.h>
^~~~~~~~~~~~~
compilation terminated.
解决:
sudo apt install libosmesa6-dev
>> mex ~/t/RenderMex.cpp
Building with 'g++'.
Warning: You are using gcc version '7.3.0'. The version of gcc is not
supported. The version currently supported with MEX is '4.9.x'. For a list
of currently supported compilers see:
http://www.mathworks.com/support/compilers/current_release.
Error using mex
/tmp/mex_20082904903412_12051/RenderMex.o: In function `mexFunction':
RenderMex.cpp:(.text+0xde): undefined reference to `OSMesaCreateContextExt'
RenderMex.cpp:(.text+0x11d): undefined reference to `OSMesaMakeCurrent'
RenderMex.cpp:(.text+0x134): undefined reference to `OSMesaPixelStore'
RenderMex.cpp:(.text+0x13e): undefined reference to `glEnable'
RenderMex.cpp:(.text+0x148): undefined reference to `glDisable'
RenderMex.cpp:(.text+0x152): undefined reference to `glDisable'
RenderMex.cpp:(.text+0x161): undefined reference to `glPolygonMode'
RenderMex.cpp:(.text+0x16b): undefined reference to `glClear'
RenderMex.cpp:(.text+0x183): undefined reference to `glViewport'
RenderMex.cpp:(.text+0x334): undefined reference to `glMatrixMode'
RenderMex.cpp:(.text+0x340): undefined reference to `glLoadMatrixd'
RenderMex.cpp:(.text+0x34a): undefined reference to `glMatrixMode'
RenderMex.cpp:(.text+0x34f): undefined reference to `glLoadIdentity'
RenderMex.cpp:(.text+0x379): undefined reference to `glColor3ubv'
RenderMex.cpp:(.text+0x383): undefined reference to `glBegin'
RenderMex.cpp:(.text+0x391): undefined reference to `glVertex3dv'
RenderMex.cpp:(.text+0x3a0): undefined reference to `glVertex3dv'
RenderMex.cpp:(.text+0x3af): undefined reference to `glVertex3dv'
RenderMex.cpp:(.text+0x3c2): undefined reference to `glVertex3dv'
RenderMex.cpp:(.text+0x3c7): undefined reference to `glEnd'
RenderMex.cpp:(.text+0x3d1): undefined reference to `glFinish'
RenderMex.cpp:(.text+0x3f9): undefined reference to `OSMesaGetDepthBuffer'
RenderMex.cpp:(.text+0x476): undefined reference to `OSMesaDestroyContext'
collect2: error: ld returned 1 exit status
原来是指令有问题,查了一下mex file.cpp
后面应该加上-l+库
>> mex ~/t/RenderMex.cpp -lGLU -lGL -lglut
Building with 'g++'.
Warning: You are using gcc version '7.3.0'. The version of gcc is not
supported. The version currently supported with MEX is '4.9.x'. For a list
of currently supported compilers see:
http://www.mathworks.com/support/compilers/current_release.
Error using mex
/tmp/mex_22286678322691_12051/RenderMex.o: In function `mexFunction':
RenderMex.cpp:(.text+0xde): undefined reference to
`OSMesaCreateContextExt'
RenderMex.cpp:(.text+0x11d): undefined reference to `OSMesaMakeCurrent'
RenderMex.cpp:(.text+0x134): undefined reference to `OSMesaPixelStore'
RenderMex.cpp:(.text+0x3f9): undefined reference to `OSMesaGetDepthBuffer'
RenderMex.cpp:(.text+0x476): undefined reference to `OSMesaDestroyContext'
collect2: error: ld returned 1 exit status
OSMesa
的函数无法引用,试了一下加一句-l
>> mex ~/t/RenderMex.cpp -lGLU -lGL -lglut -lomesa
Building with 'g++'.
Warning: You are using gcc version '7.3.0'. The version of gcc is not
supported. The version currently supported with MEX is '4.9.x'. For a list
of currently supported compilers see:
http://www.mathworks.com/support/compilers/current_release.
Error using mex
/usr/bin/ld: cannot find -lomesa
collect2: error: ld returned 1 exit status
2018/12/8
新的一天已经出现,旧的error让我停滞不前
换在windows系统下跑matlab,但是始终找不到GL/xxx
头文件
-l
指令也找不到库

今天也没有查到解决办法呢
先放着8
-
mex -v -L. -lGLU -lGL -lglut ~/t/RenderMex.cpp
先dpkg -L libosmesa6-dev
输出:
/.
/usr
/usr/include
/usr/include/GL
/usr/include/GL/osmesa.h
/usr/lib
/usr/lib/x86_64-linux-gnu
/usr/lib/x86_64-linux-gnu/pkgconfig
/usr/lib/x86_64-linux-gnu/pkgconfig/osmesa.pc
/usr/share
/usr/share/bug
/usr/share/bug/libosmesa6-dev
/usr/share/bug/libosmesa6-dev/control
/usr/share/bug/libosmesa6-dev/script
/usr/share/doc
/usr/share/doc/libosmesa6-dev
/usr/share/doc/libosmesa6-dev/copyright
/usr/lib/x86_64-linux-gnu/libOSMesa.so
/usr/share/doc/libosmesa6-dev/changelog.Debian.gz
将上面的文件夹通过set path->add folders...
添加到路径
然后mex -v -L. -lGLU -lGL -lglut ~/t/RenderMex.cpp
Verbose mode is on.
No MEX options file identified; looking for an implicit selection.
... Looking for compiler 'g++' ...
... Executing command 'which g++' ...Yes ('/usr/bin/g++').
... Executing command 'g++ -print-file-name=libstdc++.so' ...Yes ('/usr/lib/gcc/x86_64-linux-gnu/7/libstdc++.so').
Found installed compiler 'g++'.
Options file details
-------------------------------------------------------------------
Compiler location: /usr/bin/g++
Options file: /usr/local/MATLAB/R2017b/bin/glnxa64/mexopts/g++_glnxa64.xml
CMDLINE2 : /usr/bin/g++ -pthread -Wl,--no-undefined -shared -O -Wl,--version-script,"/usr/local/MATLAB/R2017b/extern/lib/glnxa64/c_exportsmexfileversion.map" /tmp/mex_1144657551288_1757/RenderMex.o /tmp/mex_1144657551288_1757/cpp_mexapi_version.o -lGLU -lGL -lglut -L. -Wl,-rpath-link,/usr/local/MATLAB/R2017b/bin/glnxa64 -L"/usr/local/MATLAB/R2017b/bin/glnxa64" -lmx -lmex -lmat -lm -lstdc++ -o RenderMex.mexa64
CXX : /usr/bin/g++
DEFINES : -DUSE_MEX_CMD -D_GNU_SOURCE -DMATLAB_MEX_FILE
MATLABMEX : -DMATLAB_MEX_FILE
CFLAGS : -fexceptions -fPIC -fno-omit-frame-pointer -pthread
CXXFLAGS : -fexceptions -fPIC -fno-omit-frame-pointer -pthread -std=c++11
INCLUDE : -I"/usr/local/MATLAB/R2017b/extern/include" -I"/usr/local/MATLAB/R2017b/simulink/include"
CXXOPTIMFLAGS : -O -DNDEBUG
CXXDEBUGFLAGS : -g
LDXX : /usr/bin/g++
LDFLAGS : -pthread -Wl,--no-undefined
LDTYPE : -shared
LINKEXPORT : -Wl,--version-script,"/usr/local/MATLAB/R2017b/extern/lib/glnxa64/mexFunction.map"
LINKEXPORTVER : -Wl,--version-script,"/usr/local/MATLAB/R2017b/extern/lib/glnxa64/c_exportsmexfileversion.map"
LINKLIBS : -lGLU -lGL -lglut -L. -Wl,-rpath-link,/usr/local/MATLAB/R2017b/bin/glnxa64 -L"/usr/local/MATLAB/R2017b/bin/glnxa64" -lmx -lmex -lmat -lm -lstdc++
LDOPTIMFLAGS : -O
LDDEBUGFLAGS : -g
MWCPPLIB : "/usr/local/MATLAB/R2017b/sys/os/glnxa64/libstdc++.so.6"
OBJEXT : .o
LDEXT : .mexa64
SETENV : CC="gcc"
CXX="/usr/bin/g++"
CFLAGS="-fexceptions -fPIC -fno-omit-frame-pointer -pthread -DUSE_MEX_CMD -D_GNU_SOURCE -DMATLAB_MEX_FILE "
CXXFLAGS="-fexceptions -fPIC -fno-omit-frame-pointer -pthread -std=c++11 -DUSE_MEX_CMD -D_GNU_SOURCE -DMATLAB_MEX_FILE "
COPTIMFLAGS="-O -DNDEBUG"
CXXOPTIMFLAGS="-O -DNDEBUG"
CDEBUGFLAGS="-g"
CXXDEBUGFLAGS="-g"
LD="gcc"
LDXX="/usr/bin/g++"
LDFLAGS="-pthread -Wl,--no-undefined -shared -lGLU -lGL -lglut -L. -Wl,-rpath-link,/usr/local/MATLAB/R2017b/bin/glnxa64 -L"/usr/local/MATLAB/R2017b/bin/glnxa64" -lmx -lmex -lmat -lm -lstdc++ -Wl,--version-script,"/usr/local/MATLAB/R2017b/extern/lib/glnxa64/mexFunction.map""
LDDEBUGFLAGS="-g"
GCC : /usr/bin/g++
CPPLIB_DIR : /usr/lib/gcc/x86_64-linux-gnu/7/libstdc++.so
MATLABROOT : /usr/local/MATLAB/R2017b
ARCH : glnxa64
SRC : "/home/quwanxin/t/RenderMex.cpp";"/usr/local/MATLAB/R2017b/extern/version/cpp_mexapi_version.cpp"
OBJ : /tmp/mex_1144657551288_1757/RenderMex.o;/tmp/mex_1144657551288_1757/cpp_mexapi_version.o
OBJS : /tmp/mex_1144657551288_1757/RenderMex.o /tmp/mex_1144657551288_1757/cpp_mexapi_version.o
SRCROOT : /home/quwanxin/t/RenderMex
DEF : /tmp/mex_1144657551288_1757/RenderMex.def
EXP : RenderMex.exp
LIB : RenderMex.lib
EXE : RenderMex.mexa64
ILK : RenderMex.ilk
MANIFEST : RenderMex.mexa64.manifest
TEMPNAME : RenderMex
EXEDIR :
EXENAME : RenderMex
OPTIM : -O -DNDEBUG
LINKOPTIM : -O
CMDLINE1_0 : /usr/bin/g++ -c -DUSE_MEX_CMD -D_GNU_SOURCE -DMATLAB_MEX_FILE -I"/usr/local/MATLAB/R2017b/extern/include" -I"/usr/local/MATLAB/R2017b/simulink/include" -fexceptions -fPIC -fno-omit-frame-pointer -pthread -std=c++11 -O -DNDEBUG "/home/quwanxin/t/RenderMex.cpp" -o /tmp/mex_1144657551288_1757/RenderMex.o
CMDLINE1_1 : /usr/bin/g++ -c -DUSE_MEX_CMD -D_GNU_SOURCE -DMATLAB_MEX_FILE -I"/usr/local/MATLAB/R2017b/extern/include" -I"/usr/local/MATLAB/R2017b/simulink/include" -fexceptions -fPIC -fno-omit-frame-pointer -pthread -std=c++11 -O -DNDEBUG "/usr/local/MATLAB/R2017b/extern/version/cpp_mexapi_version.cpp" -o /tmp/mex_1144657551288_1757/cpp_mexapi_version.o
-------------------------------------------------------------------
Building with 'g++'.
Warning: You are using gcc version '7.3.0'. The version of gcc is not supported.
The version currently supported with MEX is '4.9.x'. For a list of currently
supported compilers see:
http://www.mathworks.com/support/compilers/current_release.
/usr/bin/g++ -c -DUSE_MEX_CMD -D_GNU_SOURCE -DMATLAB_MEX_FILE -I"/usr/local/MATLAB/R2017b/extern/include" -I"/usr/local/MATLAB/R2017b/simulink/include" -fexceptions -fPIC -fno-omit-frame-pointer -pthread -std=c++11 -O -DNDEBUG "/home/quwanxin/t/RenderMex.cpp" -o /tmp/mex_1144657551288_1757/RenderMex.o
/usr/bin/g++ -c -DUSE_MEX_CMD -D_GNU_SOURCE -DMATLAB_MEX_FILE -I"/usr/local/MATLAB/R2017b/extern/include" -I"/usr/local/MATLAB/R2017b/simulink/include" -fexceptions -fPIC -fno-omit-frame-pointer -pthread -std=c++11 -O -DNDEBUG "/usr/local/MATLAB/R2017b/extern/version/cpp_mexapi_version.cpp" -o /tmp/mex_1144657551288_1757/cpp_mexapi_version.o
/usr/bin/g++ -pthread -Wl,--no-undefined -shared -O -Wl,--version-script,"/usr/local/MATLAB/R2017b/extern/lib/glnxa64/c_exportsmexfileversion.map" /tmp/mex_1144657551288_1757/RenderMex.o /tmp/mex_1144657551288_1757/cpp_mexapi_version.o -lGLU -lGL -lglut -L. -Wl,-rpath-link,/usr/local/MATLAB/R2017b/bin/glnxa64 -L"/usr/local/MATLAB/R2017b/bin/glnxa64" -lmx -lmex -lmat -lm -lstdc++ -o RenderMex.mexa64
Error using mex
/tmp/mex_1144657551288_1757/RenderMex.o: In function `mexFunction':
RenderMex.cpp:(.text+0xde): undefined reference to `OSMesaCreateContextExt'
RenderMex.cpp:(.text+0x11d): undefined reference to `OSMesaMakeCurrent'
RenderMex.cpp:(.text+0x134): undefined reference to `OSMesaPixelStore'
RenderMex.cpp:(.text+0x3f9): undefined reference to `OSMesaGetDepthBuffer'
RenderMex.cpp:(.text+0x476): undefined reference to `OSMesaDestroyContext'
collect2: error: ld returned 1 exit status
似乎一点用也没有呢😊
Reference
存个链接:windows下matlab调用opengl
网友评论