0

I am trying to compile cpp files from this link, but I am receiving the following errors:

>> mex OpticalFlow.cpp

LINK : error LNK2001: unresolved external symbol mexFunction   
C:\Users\pc\AppData\Local\Temp\mex_Fe1hah\templib.x :   
fatal error LNK1120: 1 unresolved externals    
E:\MATLAB2\R2013A\BIN\MEX.PL: Error: Link of 'OpticalFlow.mexw32' failed. 

>> mex GaussianPyramid.cpp

LINK : error LNK2001: unresolved external symbol mexFunction  
C:\Users\pc\AppData\Local\Temp\mex_IWT6TB\templib.x : fatal error LNK1120: 1 unresolved externals  
E:\MATLAB2\R2013A\BIN\MEX.PL: Error: Link of 'GaussianPyramid.mexw32' failed.   
Creating library C:\Users\pc\AppData\Local\Temp\mex_5guviT\templib.x and object  C:\Users\pc\AppData\Local\Temp\mex_5guviT\templib.exp  
Coarse2FineTwoFrames.obj : error LNK2019: unresolved external symbol "public: static void __cdecl OpticalFlow::Coarse2FineFlow(class Image<double> &,class Image<double> &,class Image<double> &,class Image<double> const &,class Image<double> const &,double,double,int,int,int,int)" (?Coarse2FineFlow@OpticalFlow@@SAXAAV?$Image@N@@00ABV2@1NNHHHH@Z) referenced in function _mexFunction  
Coarse2FineTwoFrames.mexw32 : fatal error LNK1120: 1 unresolved externals   
E:\MATLAB2\R2013A\BIN\MEX.PL: Error: Link of 'Coarse2FineTwoFrames.mexw32' failed.   
Error using mex (line 206)  
Unable to complete successfully.  

Can somebody help me, please?

Zorawar
  • 6,505
  • 2
  • 23
  • 41
Sam
  • 35
  • 6
  • 2
    I am assuming you followed the instructions? From the site: "How to use? The core of the package is written in C++ and mexed to dll to be called in Matlab. In the /OpticalFlow/mex folder, run the following: mex Coarse2FineTwoFrames.cpp GaussianPyramid.cpp OpticalFlow.cpp" – Buck Thorn Jan 11 '15 at 13:53

1 Answers1

1

The package you are trying to compile consists of three cpp files, but they should be compiled into a single mex file.
as a result they only have one mexFunction symbol defined in them.
Try

>> mex -O -largeArrayDims Coarse2FineTwoFrames.cpp GaussianPyramid.cpp OpticalFlow.cpp
Shai
  • 111,146
  • 38
  • 238
  • 371
  • Indeed sir, I read the instructions. Now that I compile it into one mex file. I experience this error c:\users\pc\desktop\opticalflow\mex\Stochastic.h(11) : warning C4067: unexpected tokens following preprocessor directive - expected a newline c:\users\pc\desktop\opticalflow\mex\NoiseModel.h(6) : warning C4005: 'PI' : macro redefinition c:\users\pc\desktop\opticalflow\mex\Stochastic.h(16) : see previous definition of 'PI' – Sam Jan 11 '15 at 14:04
  • Also, warning warning C4244: '=' : conversion from 'double' to 'int', possible loss of data – Sam Jan 11 '15 at 14:05
  • @Sam: These are warnings, not errors. The mex should be compiled successfully. – Daniel Jan 11 '15 at 14:10
  • 1
    Thank U sir shai, It works. You are savior I get the results. – Sam Jan 11 '15 at 14:14