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
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