1

我经常使用 matlab,但不会使用太多 C(我稍后会介绍)。我正在尝试安装一个名为SharedMatrix的 mex 文件。安装需要 Boost 的进程间库。

要在 Matlab 上安装 SharedMatrix,我输入:

mex -v -O -win32 -I'C:\Program Files\boost\boost_1_51' SharedMemory.cpp

我得到的确切输出是:

*************************************************************************** 
  Warning: Neither -compatibleArrayDims nor -largeArrayDims is selected.  
           Using -compatibleArrayDims. In the future, MATLAB will require 
           the use of -largeArrayDims and remove the -compatibleArrayDims  
           option. For more information, see: 
           http://www.mathworks.com/help/techdoc/matlab_external/bsflnue-1.html 
**************************************************************************** 

-> Default options filename found in C:\Users\Skyhr\AppData\Roaming\MathWorks\MATLAB\R2012b 
---------------------------------------------------------------- 
->    Options file           = C:\Users\Skyhr\AppData\Roaming\MathWorks\MATLAB\R2012b\mexopts.bat 
      MATLAB                 = C:\Program Files\MATLAB\R2012b 
->    COMPILER               = lcc 
->    Compiler flags: 
         COMPFLAGS           = -c -I"C:\Program Files\MATLAB\R2012b\sys\lcc\include" -DMATLAB_MEX_FILE -noregistrylookup 
         OPTIMFLAGS          = -DNDEBUG 
         DEBUGFLAGS          = -g4 
         arguments           =  -I"C:\Program Files\boost\boost_1_51" 
         Name switch         = -Fo 
->    Pre-linking commands   =  
->    LINKER                 = lcclnk 
->    Link directives: 
         LINKFLAGS           =  -tmpdir "." -dll "C:\Program Files\MATLAB\R2012b\extern\lib\win32\lcc\mexFunction.def" -L"C:\Program Files\MATLAB\R2012b\sys\lcc\lib" -libpath "C:\Program Files\MATLAB\R2012b\extern\lib\win32\lcc" "C:\Users\Skyhr\AppData\Local\Temp\mex_5NkIuB\templib2.obj" 
         LINKDEBUGFLAGS      =  
         LINKFLAGSPOST       = libmx.lib libmex.lib libmat.lib 
         Name directive      = -o "SharedMemory.mexw32" 
         File link directive =  
         Lib. link directive =  
         Rsp file indicator  = @ 
->    Resource Compiler      = lrc -I"C:\Program Files\MATLAB\R2012b\sys\lcc\include" -noregistrylookup -fo"mexversion.res" 
->    Resource Linker        =  
---------------------------------------------------------------- 


--> lcc  -I"C:\Program Files\boost\boost_1_51" -c -I"C:\Program Files\MATLAB\R2012b\sys\lcc\include" -DMATLAB_MEX_FILE -noregistrylookup -FoC:\Users\Skyhr\AppData\Local\Temp\mex_5NkIuB\SharedMemory.obj -I"C:\Program Files\MATLAB\R2012b\extern\include" -I"C:\Program Files\MATLAB\R2012b\simulink\include" -DNDEBUG -DMX_COMPAT_32 SharedMemory.cpp 

lcc preprocessor error: C:\Program Files\boost\boost_1_51\boost\interprocess\interprocess_fwd.hpp:21 C:\Program Files\boost\boost_1_51\boost\interprocess\mapped_region.hpp:17 .\SharedMemStack.hpp:9 .\SharedMemory.hpp:92 SharedMemory.cpp:62 Could not find include file <cstddef> 
lcc preprocessor error: C:\Program Files\boost\boost_1_51\boost\interprocess\interprocess_fwd.hpp:38 C:\Program Files\boost\boost_1_51\boost\interprocess\mapped_region.hpp:17 .\SharedMemStack.hpp:9 .\SharedMemory.hpp:92 SharedMemory.cpp:62 Could not find include file <utility> 
lcc preprocessor error: C:\Program Files\boost\boost_1_51\boost\interprocess\interprocess_fwd.hpp:39 C:\Program Files\boost\boost_1_51\boost\interprocess\mapped_region.hpp:17 .\SharedMemStack.hpp:9 .\SharedMemory.hpp:92 SharedMemory.cpp:62 Could not find include file <memory> 
lcc preprocessor error: C:\Program Files\boost\boost_1_51\boost\interprocess\interprocess_fwd.hpp:40 C:\Program Files\boost\boost_1_51\boost\interprocess\mapped_region.hpp:17 .\SharedMemStack.hpp:9 .\SharedMemory.hpp:92 SharedMemory.cpp:62 Could not find include file <functional> 
lcc preprocessor error: C:\Program Files\boost\boost_1_51\boost\interprocess\interprocess_fwd.hpp:41 C:\Program Files\boost\boost_1_51\boost\interprocess\mapped_region.hpp:17 .\SharedMemStack.hpp:9 .\SharedMemory.hpp:92 SharedMemory.cpp:62 Could not find include file <iosfwd> 
lcc preprocessor error: C:\Program Files\boost\boost_1_51\boost\interprocess\interprocess_fwd.hpp:42 C:\Program Files\boost\boost_1_51\boost\interprocess\mapped_region.hpp:17 .\SharedMemStack.hpp:9 .\SharedMemory.hpp:92 SharedMemory.cpp:62 Could not find include file <string> 
Error SharedMemory.cpp: C:\Program Files\boost\boost_1_51\boost\interprocess\interprocess_fwd.hpp: 28  syntax error; found `boost' expecting `;' 
Error SharedMemory.cpp: C:\Program Files\boost\boost_1_51\boost\interprocess\interprocess_fwd.hpp: 28  syntax error; found `{' expecting `;' 
Error SharedMemory.cpp: C:\Program Files\boost\boost_1_51\boost\interprocess\interprocess_fwd.hpp: 28  skipping `{' 
Error SharedMemory.cpp: C:\Program Files\boost\boost_1_51\boost\interprocess\interprocess_fwd.hpp: 29  syntax error; found `intrusive' expecting `;' 
Error SharedMemory.cpp: C:\Program Files\boost\boost_1_51\boost\interprocess\interprocess_fwd.hpp: 29  syntax error; found `{' expecting `;' 
Error SharedMemory.cpp: C:\Program Files\boost\boost_1_51\boost\interprocess\interprocess_fwd.hpp: 29  skipping `{' `}' `}' 
Error SharedMemory.cpp: C:\Program Files\boost\boost_1_51\boost\interprocess\interprocess_fwd.hpp: 32  syntax error; found `boost' expecting `;' 
Error SharedMemory.cpp: C:\Program Files\boost\boost_1_51\boost\interprocess\interprocess_fwd.hpp: 32  syntax error; found `{' expecting `;' 
Error SharedMemory.cpp: C:\Program Files\boost\boost_1_51\boost\interprocess\interprocess_fwd.hpp: 32  skipping `{' 
Error SharedMemory.cpp: C:\Program Files\boost\boost_1_51\boost\interprocess\interprocess_fwd.hpp: 33  syntax error; found `interprocess' expecting `;' 
Error SharedMemory.cpp: C:\Program Files\boost\boost_1_51\boost\interprocess\interprocess_fwd.hpp: 33  syntax error; found `{' expecting `;' 
Error SharedMemory.cpp: C:\Program Files\boost\boost_1_51\boost\interprocess\interprocess_fwd.hpp: 33  skipping `{' 
Error SharedMemory.cpp: C:\Program Files\boost\boost_1_51\boost\interprocess\interprocess_fwd.hpp: 34  syntax error; found `bi' expecting `;' 
Error SharedMemory.cpp: C:\Program Files\boost\boost_1_51\boost\interprocess\interprocess_fwd.hpp: 34  initializer must be constant 
Error SharedMemory.cpp: C:\Program Files\boost\boost_1_51\boost\interprocess\interprocess_fwd.hpp: 34  too many errors 

  C:\PROGRA~1\MATLAB\R2012B\BIN\MEX.PL: Error: Compile of 'SharedMemory.cpp' failed.

你能 1. 解释错误 2. 我该如何解决这个问题?

4

1 回答 1

0

在您的系统mex上配置为使用lcc编译器,它是一个 C 编译器。Boost 是一个 C++ 库;因此您无法使用lcc编译使用 Boost 的程序。

运行mex -setup并选择 C++ 编译器。

如果您没有安装任何其他编译器,则必须先安装一个。在 Windows 上,R2012B 支持免费的Visual Studio 2010 Express Edition C++ 编译器。下载并安装它,然后尝试mex再次运行该命令(运行后mex -setup)。

于 2013-01-01T10:46:33.410 回答