필터 지우기
필터 지우기

MEX compilation error with included paths

조회 수: 4 (최근 30일)
Saul Armendariz
Saul Armendariz 2017년 2월 1일
댓글: Saul Armendariz 2017년 2월 3일
Hello, I am having a problem trying to compile a *.cpp file.
I have VisualStudio 2015, OpenCV 3.1.0, Matlab 2016a
Every time I try to create a MEX file I get a similar error.
When I run:
mex mex_main.cpp
I get the following error:
Building with 'Microsoft Visual C++ 2015 Professional'.
Error using mex
mex_main.cpp
C:\...\mex_main.cpp(20): fatal error C1083:
Cannot open include file: 'cv.h': No such file or directory
Following other examples, I modified the mex function
mex mex_main.cpp -I'C:\opencv\build\include\opencv' -I'C:\opencv\build\include\opencv2'
to include the directories where 'cv.h' is. But I keep having a similar problem.
Building with 'Microsoft Visual C++ 2015 Professional'.
Error using mex
mex_main.cpp
C:\opencv\build\include\opencv\cv.h(63): fatal error C1083: Cannot open include file: 'core_c.h': No such file or
directory
And the problem persists even if I add those directories.
mex mex_main.cpp -I'C:\opencv\build\include\opencv' -I'C:\opencv\build\include\opencv2' I'C:\opencv\build\include\opencv2\core'
Building with 'Microsoft Visual C++ 2015 Professional'.
Error using mex
mex_main.cpp
C:\opencv\build\include\opencv2\core\core_c.h(48): fatal error C1083: Cannot open include file: 'opencv2/core/types_c.h':
No such file or directory
Any idea of how can I fix this problem?
Thank you
  댓글 수: 2
Jan
Jan 2017년 2월 1일
Did you forget the "-" before "I'C:\opencv\build\include\opencv2\core'" in the last code?
Saul Armendariz
Saul Armendariz 2017년 2월 1일
Yes, I am sorry. I accidentally delete the '-' while giving format to the text. The entry code contained the '-'

댓글을 달려면 로그인하십시오.

답변 (1개)

Jan
Jan 2017년 2월 1일
Does this help:
-I'C:\opencv\build\include\'
?
  댓글 수: 3
Jan
Jan 2017년 2월 1일
편집: Jan 2017년 2월 1일
Well, this sounds annoying. But try it:
List = dir('C:\opencv\build\include\opencv2');
Folder = {List([List.isdir]).name};
Other = {'C:\opencv\build\include', ...
'C:\opencv\build\include\opencv', ...
'C:\opencv\build\include\opencv2'};
Arg = strcat('-I', cat(2, Folder, Other));
mex('mex_main.cpp', '-O', Arg{:});
Are the quotes required around the folders? Then:
Arg = strcat('-I''', Folder, char(39));
(char(39) because '''' confuses me).
Sigh. If this works, you do not have to do this manually at least. But actually I'd expect that there is an easier way.
How are the file included? With #include "." or #include < . >?
Saul Armendariz
Saul Armendariz 2017년 2월 3일
Hi, I tried to again using your example, unfortunatly, I am still having the same problem.
I tried adding every single folder into the code. Sadly, I am still unable to create the MEX file, this time I get a different error.
Building with 'Microsoft Visual C++ 2015 Professional'.
Error using mex
mex_main.cpp
C:\...\mex_main.cpp(27): error C3861: 'mxArr_to_new_CvMat': identifier
not found
C:\...\mex_main.cpp(33): error C3861: 'CvMat_to_new_mxArr': identifier
not found
The files in the *.cpp file are included with #include < . >.
The file I am trying to run is an example taken from here . I have tried to create the MEX file following the instruction but the original error persist.
Any idea what is causing this?

댓글을 달려면 로그인하십시오.

태그

Community Treasure Hunt

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

Start Hunting!

Translated by