Clear Filters
Clear Filters

Strange errors when compiling using mex

1 view (last 30 days)
Gil
Gil on 19 Aug 2012
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.
  3 Comments
Gil
Gil on 20 Aug 2012
Hi, I'm using the following compiler:
Lcc-win32 C 2.4.1
Location: C:\PROGRA~2\MATLAB\R2008B~1\sys\lcc
Thanks!
Gil.
Jan
Jan on 21 Aug 2012
When you have MSVC installed on your computer, it would be a good idea to use it to compile MEX files also.

Sign in to comment.

Answers (1)

Walter Roberson
Walter Roberson on 20 Aug 2012
lcc is a C compiler which cannot be used to compile C++.

Categories

Find more on Write C Functions Callable from MATLAB (MEX Files) in Help Center and File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!