C++ Mex compilation error. SharedMemory.cpp
3 views (last 30 days)
Show older comments
Hello,
I am trying to compile a SharedMemory.cpp via mex and Visual Studio 2010 c++ compiler on a Win32 machine.
What I input :
mex -v -O -win32 -I'C:\Program Files\Boost\boost_1_51' SharedMemory.cpp
The output :
-> 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 = cl
-> Compiler flags:
COMPFLAGS = /c /GR /W3 /EHs /D_CRT_SECURE_NO_DEPRECATE /D_SCL_SECURE_NO_DEPRECATE /D_SECURE_SCL=0 /DMATLAB_MEX_FILE /nologo /MD
OPTIMFLAGS = /O2 /Oy- /DNDEBUG
DEBUGFLAGS = /Z7
arguments = -I"C:\Program Files\Boost\boost_1_51"
Name switch = /Fo
-> Pre-linking commands =
-> LINKER = link
-> Link directives:
LINKFLAGS = /dll /export:mexFunction /LIBPATH:"C:\Program Files\MATLAB\R2012b\extern\lib\win32\microsoft" libmx.lib libmex.lib libmat.lib /MACHINE:X86 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /manifest /incremental:NO /implib:"C:\Users\Skyhr\AppData\Local\Temp\mex_hno3II\templib.x" /MAP:"SharedMemory.mexw32.map"
LINKDEBUGFLAGS = /debug /PDB:"SharedMemory.mexw32.pdb"
LINKFLAGSPOST =
Name directive = /out:"SharedMemory.mexw32"
File link directive =
Lib. link directive =
Rsp file indicator = @
-> Resource Compiler = rc /fo "mexversion.res"
-> Resource Linker =
----------------------------------------------------------------
--> cl -I"C:\Program Files\Boost\boost_1_51" /c /GR /W3 /EHs /D_CRT_SECURE_NO_DEPRECATE /D_SCL_SECURE_NO_DEPRECATE /D_SECURE_SCL=0 /DMATLAB_MEX_FILE /nologo /MD /FoC:\Users\Skyhr\AppData\Local\Temp\mex_hno3II\SharedMemory.obj -I"C:\Program Files\MATLAB\R2012b\extern\include" -I"C:\Program Files\MATLAB\R2012b\simulink\include" /O2 /Oy- /DNDEBUG -DMX_COMPAT_32 SharedMemory.cpp
SharedMemory.cpp
SharedMemory.cpp(125) : warning C4996: 'strcmpi': The POSIX name for this item is deprecated. Instead, use the ISO C++ conformant name: _strcmpi. See online help for details.
C:\Program Files\Microsoft Visual Studio 10.0\VC\INCLUDE\string.h(245) : see declaration of 'strcmpi'
SharedMemory.cpp(177) : warning C4996: 'strcmpi': The POSIX name for this item is deprecated. Instead, use the ISO C++ conformant name: _strcmpi. See online help for details.
C:\Program Files\Microsoft Visual Studio 10.0\VC\INCLUDE\string.h(245) : see declaration of 'strcmpi'
SharedMemory.cpp(231) : warning C4996: 'strcmpi': The POSIX name for this item is deprecated. Instead, use the ISO C++ conformant name: _strcmpi. See online help for details.
C:\Program Files\Microsoft Visual Studio 10.0\VC\INCLUDE\string.h(245) : see declaration of 'strcmpi'
SharedMemory.cpp(262) : warning C4996: 'strcmpi': The POSIX name for this item is deprecated. Instead, use the ISO C++ conformant name: _strcmpi. See online help for details.
C:\Program Files\Microsoft Visual Studio 10.0\VC\INCLUDE\string.h(245) : see declaration of 'strcmpi'
SharedMemory.cpp(546) : error C2027: use of undefined type 'mxArray_tag'
c:\users\skyhr\dropbox\matlab\sharedmatrix_windows_by_andrew_smith\SharedMemory.hpp(83) : see declaration of 'mxArray_tag'
SharedMemory.cpp(546) : error C2227: left of '->data' must point to class/struct/union/generic type
SharedMemory.cpp(546) : error C2228: left of '.number_array' must have class/struct/union
SharedMemory.cpp(546) : error C2228: left of '.reserved5' must have class/struct/union
SharedMemory.cpp(547) : error C2027: use of undefined type 'mxArray_tag'
c:\users\skyhr\dropbox\matlab\sharedmatrix_windows_by_andrew_smith\SharedMemory.hpp(83) : see declaration of 'mxArray_tag'
SharedMemory.cpp(547) : error C2227: left of '->data' must point to class/struct/union/generic type
SharedMemory.cpp(547) : error C2228: left of '.number_array' must have class/struct/union
SharedMemory.cpp(547) : error C2228: left of '.reserved6' must have class/struct/union
SharedMemory.cpp(548) : error C2027: use of undefined type 'mxArray_tag'
c:\users\skyhr\dropbox\matlab\sharedmatrix_windows_by_andrew_smith\SharedMemory.hpp(83) : see declaration of 'mxArray_tag'
SharedMemory.cpp(548) : error C2227: left of '->data' must point to class/struct/union/generic type
SharedMemory.cpp(548) : error C2228: left of '.number_array' must have class/struct/union
SharedMemory.cpp(548) : error C2228: left of '.reserved6' must have class/struct/union
SharedMemory.cpp(584) : error C2027: use of undefined type 'mxArray_tag'
c:\users\skyhr\dropbox\matlab\sharedmatrix_windows_by_andrew_smith\SharedMemory.hpp(83) : see declaration of 'mxArray_tag'
SharedMemory.cpp(584) : error C2227: left of '->data' must point to class/struct/union/generic type
SharedMemory.cpp(584) : error C2228: left of '.number_array' must have class/struct/union
SharedMemory.cpp(584) : error C2228: left of '.pdata' must have class/struct/union
SharedMemory.cpp(586) : error C2027: use of undefined type 'mxArray_tag'
c:\users\skyhr\dropbox\matlab\sharedmatrix_windows_by_andrew_smith\SharedMemory.hpp(83) : see declaration of 'mxArray_tag'
SharedMemory.cpp(586) : error C2227: left of '->data' must point to class/struct/union/generic type
SharedMemory.cpp(586) : error C2228: left of '.number_array' must have class/struct/union
SharedMemory.cpp(586) : error C2228: left of '.pimag_data' must have class/struct/union
C:\PROGRA~1\MATLAB\R2012B\BIN\MEX.PL: Error: Compile of 'SharedMemory.cpp' failed.
I am not very familiar with C++. Can someone please explain what the error is and how to fix it? From seeing others use this without any problems - the code should be working because others have compiled it and are using it without any problems. The cpp file uses libraries from the Boost library.
0 Comments
Accepted Answer
James Tursa
on 3 Jan 2013
Edited: James Tursa
on 3 Jan 2013
It looks like you are missing the definition of the struct mxArray_tag. This used to be part of the matrix.h file up to R2010a, but has since been deleted. Since you are using R2012b my guess is that is the root problem. The fix may be to simply include it manually based on what was published in an older version. E.g., see this link to Yair Altman's Undocumented MATLAB site for examples:
5 Comments
James Tursa
on 3 Jan 2013
Where is libboost_date_time-vc100-mt-1_51.lib located? Try putting in in the same directory as SharedMemory.cpp.
More Answers (0)
See Also
Categories
Find more on MATLAB Compiler in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!