Hi,
I'm compiling with mex and I'm getting a few strange errors. I'm sure that there aren’t any errors in my cpp code (when opening the code in Visual Studio for example, I get no errors) so I really don't understand what's wrong with my code.
I'm compiling using the following line:
mex mexDenseSIFT.cpp Matrix.cpp Vector.cpp
and I'm getting the following errors (those are only the first few errors):
Error C:\FACERE~1\SIFTFL~1\MEXDEN~1\mexDenseSIFT.cpp: C:\FACERE~1\SIFTFL~1\MEXDEN~1\project.h: 8 syntax error; found `<' expecting `;' Error C:\FACERE~1\SIFTFL~1\MEXDEN~1\mexDenseSIFT.cpp: C:\FACERE~1\SIFTFL~1\MEXDEN~1\project.h: 8 skipping `<' Error C:\FACERE~1\SIFTFL~1\MEXDEN~1\mexDenseSIFT.cpp: C:\FACERE~1\SIFTFL~1\MEXDEN~1\project.h: 8 syntax error; found `T' expecting `;' Error C:\FACERE~1\SIFTFL~1\MEXDEN~1\mexDenseSIFT.cpp: C:\FACERE~1\SIFTFL~1\MEXDEN~1\project.h: 8 syntax error; found `>' expecting `;' Error C:\FACERE~1\SIFTFL~1\MEXDEN~1\mexDenseSIFT.cpp: C:\FACERE~1\SIFTFL~1\MEXDEN~1\project.h: 8 skipping `>' Error C:\FACERE~1\SIFTFL~1\MEXDEN~1\mexDenseSIFT.cpp: C:\FACERE~1\SIFTFL~1\MEXDEN~1\project.h: 9 syntax error; found `*' expecting `)' Error C:\FACERE~1\SIFTFL~1\MEXDEN~1\mexDenseSIFT.cpp: C:\FACERE~1\SIFTFL~1\MEXDEN~1\project.h: 9 skipping `*' `pBuffer'
Here is the file project.h:
#pragma once #include "stdio.h"
// if the files are compiled in linux or mac os then uncomment the following line, otherwise comment it if you compile using visual studio in windows //#define _LINUX_MAC #define _OPENCV
template <class T>
void _Release1DBuffer(T* pBuffer)
{
if(pBuffer!=NULL)
delete []pBuffer;
pBuffer=NULL;
}
template <class T>
void _Rlease2DBuffer(T** pBuffer,size_t nElements)
{
for(size_t i=0;i<nElements;i++)
delete [](pBuffer[i]);
delete []pBuffer;
pBuffer=NULL;
}
#define _MATLAB
#ifdef _MATLAB #include "mex.h" #endif
#ifdef _LINUX_MAC
template <class T1,class T2>
T1 __min(T1 a, T2 b)
{
return (a>b)?b:a;
}
template <class T1,class T2>
T1 __max(T1 a, T2 b)
{
return (a<b)?b:a;
}
#endif
Now, if I'm not missing anything, I can't see no problem with project.h. Moreover, the first few errors (which I quoted above) relate to line 8, which is:
template <class T>
And I really can't see any error here.
Can someone please tell me what am I missing here?
Thanks!
Gil.
No products are associated with this question.
lcc is a C compiler which cannot be used to compile C++.
3 Comments
Direct link to this comment:
http://mathworks.com/matlabcentral/answers/46297#comment_95268
Which compiler are you using?
Direct link to this comment:
http://mathworks.com/matlabcentral/answers/46297#comment_95348
Hi, I'm using the following compiler:
Lcc-win32 C 2.4.1
Location: C:\PROGRA~2\MATLAB\R2008B~1\sys\lcc
Thanks!
Gil.
Direct link to this comment:
http://mathworks.com/matlabcentral/answers/46297#comment_95452
When you have MSVC installed on your computer, it would be a good idea to use it to compile MEX files also.