MEX compilation error with included paths
조회 수: 4 (최근 30일)
이전 댓글 표시
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
2017년 2월 1일
Did you forget the "-" before "I'C:\opencv\build\include\opencv2\core'" in the last code?
답변 (1개)
Jan
2017년 2월 1일
Does this help:
-I'C:\opencv\build\include\'
?
댓글 수: 3
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 < . >?
참고 항목
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!