Hi Lorgio, I gave up compiling SerialIO within matlab. Correct me if I am wrong but the maltab internal lcc compiler won't compile serialIO.cpp correctly and hence a c++ compiler should be used. I set up my vc++ compiler (Visual C++ 2008) to compile the mex file via vc++ (see http://www.icaen.uiowa.edu/~dip/lecture/C++_with_Matlab.pdf). I am getting following errors (seems some of the syntax has c slang that the c++ compiler rejects):
1><path>\visual studio 2008\projects\mexserialio\mexserialio\serialio.cpp(332) : warning C4996: 'sprintf': This function or variable may be unsafe. Consider using sprintf_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.
1> f:\vc++\vc\include\stdio.h(366) : see declaration of 'sprintf'
1><path>\visual studio 2008\projects\mexserialio\mexserialio\serialio.cpp(363) : error C2664: 'CreateFileW' : cannot convert parameter 1 from 'char [255]' to 'LPCWSTR'
1> Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast
1><path>\visual studio 2008\projects\mexserialio\mexserialio\serialio.cpp(403) : error C2664: '_beginthread' : cannot convert parameter 1 from 'unsigned int (__stdcall *)(void)' to 'void (__cdecl *)(void *)'
1> This conversion requires a reinterpret_cast, a C-style cast or function-style cast
1><path>\visual studio 2008\projects\mexserialio\mexserialio\serialio.cpp(453) : error C2440: '=' : cannot convert from 'void *' to 'char *'
1> Conversion from 'void*' to pointer to non-'void' requires an explicit cast
1><path>\visual studio 2008\projects\mexserialio\mexserialio\serialio.cpp(469) : error C2440: '=' : cannot convert from 'const mxArray *' to 'mxArray *'
1> Conversion loses qualifiers
1><path>\visual studio 2008\projects\mexserialio\mexserialio\serialio.cpp(471) : error C2440: '=' : cannot convert from 'void *' to 'char *'
1> Conversion from 'void*' to pointer to non-'void' requires an explicit cast
1>Build log was saved at "file://<path>\Visual Studio 2008\Projects\mexSerialIO\mexSerialIO\Debug\BuildLog.htm"
1>mexSerialIO - 5 error(s), 1 warning(s)
Any ideas? Feedback highly appreciated. In the original code, sleep was written lower case. Changing e.g. 'sleep(5)' to 'Sleep(5)' removed 3 errors.... quite picky compiler....
Thanks a lot!
Chris
06 Oct 2009
SerialIO mex
SerialIO is written in C and allows you to read/write to a serial or com port.
Author: Lorgio Teodovich
I am using R2009b on a 64 bit Windows 7 machine with Visual Studio 2008 as my compiler.
When I try to compile I get:
>> mex SerialIO.cpp
SerialIO.cpp
SerialIO.cpp(73) : error C3861: 'sleep': identifier not found
SerialIO.cpp(77) : error C3861: '_endthreadex': identifier not found
SerialIO.cpp(89) : error C3861: 'sleep': identifier not found
SerialIO.cpp(93) : error C3861: 'sleep': identifier not found
SerialIO.cpp(392) : error C3861: '_beginthreadex': identifier not found
SerialIO.cpp(441) : warning C4267: '=' : conversion from 'size_t' to 'int', possible loss of data
SerialIO.cpp(442) : error C2440: '=' : cannot convert from 'void *' to 'char *'
Conversion from 'void*' to pointer to non-'void' requires an explicit cast
SerialIO.cpp(458) : error C2440: '=' : cannot convert from 'const mxArray *' to 'mxArray *'
Conversion loses qualifiers
SerialIO.cpp(460) : error C2440: '=' : cannot convert from 'void *' to 'char *'
Conversion from 'void*' to pointer to non-'void' requires an explicit cast
C:\PROGRA~1\MATLAB\R2009B\BIN\MEX.PL: Error: Compile of 'SerialIO.cpp' failed.
??? Error using ==> mex at 221
Unable to complete successfully.
It probably is my system confihuration. I'm not a c++ programmer.
Any Suggestions.
Thanks
James
Hi Lorgio, I gave up compiling SerialIO within matlab. Correct me if I am wrong but the maltab internal lcc compiler won't compile serialIO.cpp correctly and hence a c++ compiler should be used. I set up my vc++ compiler (Visual C++ 2008) to compile the mex file via vc++ (see http://www.icaen.uiowa.edu/~dip/lecture/C++_with_Matlab.pdf). I am getting following errors (seems some of the syntax has c slang that the c++ compiler rejects):
1><path>\visual studio 2008\projects\mexserialio\mexserialio\serialio.cpp(332) : warning C4996: 'sprintf': This function or variable may be unsafe. Consider using sprintf_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.
1> f:\vc++\vc\include\stdio.h(366) : see declaration of 'sprintf'
1><path>\visual studio 2008\projects\mexserialio\mexserialio\serialio.cpp(363) : error C2664: 'CreateFileW' : cannot convert parameter 1 from 'char [255]' to 'LPCWSTR'
1> Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast
1><path>\visual studio 2008\projects\mexserialio\mexserialio\serialio.cpp(403) : error C2664: '_beginthread' : cannot convert parameter 1 from 'unsigned int (__stdcall *)(void)' to 'void (__cdecl *)(void *)'
1> This conversion requires a reinterpret_cast, a C-style cast or function-style cast
1><path>\visual studio 2008\projects\mexserialio\mexserialio\serialio.cpp(453) : error C2440: '=' : cannot convert from 'void *' to 'char *'
1> Conversion from 'void*' to pointer to non-'void' requires an explicit cast
1><path>\visual studio 2008\projects\mexserialio\mexserialio\serialio.cpp(469) : error C2440: '=' : cannot convert from 'const mxArray *' to 'mxArray *'
1> Conversion loses qualifiers
1><path>\visual studio 2008\projects\mexserialio\mexserialio\serialio.cpp(471) : error C2440: '=' : cannot convert from 'void *' to 'char *'
1> Conversion from 'void*' to pointer to non-'void' requires an explicit cast
1>Build log was saved at "file://<path>\Visual Studio 2008\Projects\mexSerialIO\mexSerialIO\Debug\BuildLog.htm"
1>mexSerialIO - 5 error(s), 1 warning(s)
Any ideas? Feedback highly appreciated. In the original code, sleep was written lower case. Changing e.g. 'sleep(5)' to 'Sleep(5)' removed 3 errors.... quite picky compiler....
Thanks a lot!
Chris
Comment only
06 Oct 2009
SerialIO mex
SerialIO is written in C and allows you to read/write to a serial or com port.
James, try to compile http://www.mathworks.com/matlabcentral/fileexchange/21233
. Or add "
// undef needed for LCC compiler
#undef EXTERN_C
#include <process.h>".
I am using R2007a on a 32 bit Windows XP Sp2.
Comment only
06 Oct 2009
SerialIO mex
SerialIO is written in C and allows you to read/write to a serial or com port.
Largio.
Made the following changes to the source code and got a clean compile and it runs help ok.
Haven't tried any other functionality yet.
line 32 commented out #define Thread
added cast to lines 442,458,460
Do you think it will work with these changes
Thanks
James
Comment only
06 Oct 2009
SerialIO mex
SerialIO is written in C and allows you to read/write to a serial or com port.
Lorgio.
I am using R2009b on a 64 bit Windows 7 machine with Visual Studio 2008 as my compiler.
When I try to compile I get:
>> mex SerialIO.cpp
SerialIO.cpp
SerialIO.cpp(73) : error C3861: 'sleep': identifier not found
SerialIO.cpp(77) : error C3861: '_endthreadex': identifier not found
SerialIO.cpp(89) : error C3861: 'sleep': identifier not found
SerialIO.cpp(93) : error C3861: 'sleep': identifier not found
SerialIO.cpp(392) : error C3861: '_beginthreadex': identifier not found
SerialIO.cpp(441) : warning C4267: '=' : conversion from 'size_t' to 'int', possible loss of data
SerialIO.cpp(442) : error C2440: '=' : cannot convert from 'void *' to 'char *'
Conversion from 'void*' to pointer to non-'void' requires an explicit cast
SerialIO.cpp(458) : error C2440: '=' : cannot convert from 'const mxArray *' to 'mxArray *'
Conversion loses qualifiers
SerialIO.cpp(460) : error C2440: '=' : cannot convert from 'void *' to 'char *'
Conversion from 'void*' to pointer to non-'void' requires an explicit cast
C:\PROGRA~1\MATLAB\R2009B\BIN\MEX.PL: Error: Compile of 'SerialIO.cpp' failed.
??? Error using ==> mex at 221
Unable to complete successfully.
It probably is my system confihuration. I'm not a c++ programmer.
Any Suggestions.
Thanks
James
Comment only