error LNK2019: unresolved external symbol referenced in function mexFunction
6 次查看(过去 30 天)
显示 更早的评论
I am trying to compile a .cpp file along with a library extension, but I am getting the LNK2019 error. I've looked at all of the similar threads on here and have not been able to fix the issue, so any help you can provide is appreciated. I am not experienced in C++ so I'm guessing my issue is somewhere in the cpp file. I downloaded this whole package from GitHub so I have not written any of it except for modifying the opencv_path string.
This is my MATLAB code:
opencv_path = 'OpenCV2.2/'
openCVflags = ['-I' opencv_path 'include/ -L' opencv_path 'lib/ -lopencv_core220 -lopencv_highgui220 -lopencv_imgproc220'];
system(['mex -outdir bin ' openCVflags ' source/utils/get_video_info.cpp']);
And here is the get_video_info.cpp code:
#include<iostream>
//#include<cv.h>
//#include<cvaux.h>
//#include<highgui.h>
#include <stdio.h>
#include <stdlib.h>
#include "mex.h"
#include "opencv/cv.h"
#include "opencv/highgui.h"
using namespace std;
using namespace cv;
void mexFunction( int nlhs, mxArray *plhs[],
int nrhs, const mxArray *prhs[])
{
CvCapture* capture = NULL;
char *filename = mxArrayToString(prhs[0]);
double *x, *y, *z;
capture = cvCaptureFromFile(filename);
if (capture == NULL){
mexErrMsgTxt("Could not open video file.txt.");
}
y = mxGetPr( plhs[0] = mxCreateDoubleMatrix(1,1,mxREAL) );
*y = cvGetCaptureProperty(capture,CV_CAP_PROP_FRAME_HEIGHT );
x = mxGetPr( plhs[1] = mxCreateDoubleMatrix(1,1,mxREAL) );
*x = cvGetCaptureProperty(capture, CV_CAP_PROP_FRAME_WIDTH);
z = mxGetPr( plhs[2] = mxCreateDoubleMatrix(1,1,mxREAL) );
*z = cvGetCaptureProperty(capture, CV_CAP_PROP_FRAME_COUNT);
cvReleaseCapture(&capture);
mxFree(filename);
}
0 个评论
采纳的回答
Esha Bhargava
2018-1-12
Since the cpp file has been written by a third party, you will need to contact the author of the file to resolve issues related to the file.
0 个评论
更多回答(0 个)
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!