MEX compilation error with included paths
2 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
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 comentarios
Jan
el 1 de Feb. de 2017
Did you forget the "-" before "I'C:\opencv\build\include\opencv2\core'" in the last code?
Respuestas (1)
Jan
el 1 de Feb. de 2017
Does this help:
-I'C:\opencv\build\include\'
?
3 comentarios
Jan
el 1 de Feb. de 2017
Editada: Jan
el 1 de Feb. de 2017
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 < . >?
Ver también
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!