error LNK2019: unresolved external symbol referenced in function mexFunction

7 ビュー (過去 30 日間)
Dalton Moore
Dalton Moore 2018 年 1 月 9 日
回答済み: Esha Bhargava 2018 年 1 月 12 日
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);
}

採用された回答

Esha Bhargava
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 件)

Community Treasure Hunt

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

Start Hunting!

Translated by