Strange errors when compiling using mex
Show older comments
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.
Answers (1)
Walter Roberson
on 20 Aug 2012
1 vote
lcc is a C compiler which cannot be used to compile C++.
1 Comment
Jan
on 21 Aug 2012
Exactly.
Categories
Find more on OpenCV Support 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!