Boost mex compilation error > SharedMatrix

1 次查看(过去 30 天)
Hello, I use matlab a alot but not much C. I'm trying to use SharedMatrix ( http://www.mathworks.com/matlabcentral/fileexchange/28572-sharedmatrix). I downloaded the Boost library and tried to install/compile it with:
mex -v -O -win32 -I'C:\Program Files\boost\boost_1_51' SharedMemory.cpp
The exact output I get is:
***************************************************************************
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_7mGfwu\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_7mGfwu\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.
Could you please
  1. Explain the error to me.
  2. How do I fix this? I have used code that supposedly many people have successfully used. Why would these errors come up on my machine?

采纳的回答

James Tursa
James Tursa 2013-1-2
The supplied lcc compiler is a C compiler only, not a C++ compiler. You will not be able to compile cpp files with lcc. You need to install and select a C++ compiler to compile cpp files.
  2 个评论
Jan
Jan 2013-1-2
In addition the LCC shipped with Matlab is really old and contains serious bugs e.g. for (u)int64. Even installing a modern LCC downloaded from the net is a good idea, but modifying the mexopts.bat file is not trivial. Better install a supported, modern and efficient compiler.
Evan
Evan 2013-1-3
编辑:Evan 2013-1-3
Ah brilliant. May I ask which modern C++ compiler I should get? Also, I assume I change the compiler on Matlab with the command "mbuild -setup", yes?
Thank you
EDIT 1: Actually, I do have Visual Studio 2010, and I've changed the compiler to it via "mbuild -setup" but I keep getting the same message on lcc. What is going on?
EDIT 2: Ok, I see that "mex -setup" is the one I should have used instead of "mbuild -setup". But now I am actually getting errors on compilation. I will post this on a new question because the content is bigger than I should post on a comment window.

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 C Shared Library Integration 的更多信息

产品

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by