mex.h not found

70 ビュー (過去 30 日間)
Maia2022
Maia2022 2022 年 6 月 29 日
コメント済み: Maia2022 2022 年 7 月 4 日
Hi,
I tried to create a mex from this:
but I got an error.
My steps:
1) mex -setup
This gives a message that mex will use Visual Studio 2019
Then, I put:
2) mex ../src/kdtree.cc
But I got this error:
/Applications/Matlab_R2013b.app/externe/include/mex.h: No such file or directory
Also, what would that mean :
>> edit ../src/kdtree_common.h % Edit this file to set your system headers.
Thank you a lot for your help,
Best regards

採用された回答

Geoff Hayes
Geoff Hayes 2022 年 6 月 30 日
@Maia2022 - I have the same problem with this code because of the kdtree_common.h file where the path to the mex.h is hard-coded to that on the author's computer
// Uncomment one of these includes depending on your architecture.
// Your installation location may vary.
//
//
// For Linux use this line:
//
//#include "/usr/local/matlab/extern/include/mex.h"
//
//
// For Windows systems use this line:
//
//#include "c:\matlab_r2013b\extern\include\mex.h"
//
//
// For Mac Os X systems use this line :
//
#include "/Applications/MATLAB_R2013b.app/extern/include/mex.h"
//
//
I am using a Mac (like the author) and so need to modify the path to something slightly different using (since I have a different version of MATLAB). You will need to do the same or uncomment the include that is relevant for your OS (Linux or Windows) and ensure that the path is correct. For example, I changed the above to
#include "/Applications/MATLAB_R2021a.app/extern/include/mex.h"
and I was able to compile the code without issue.
I suspect a better fix would be to just have #include "mex.h" (as commented by @Jan in the review of the above code) and then you could compile as
mex -v -I/Applications/MATLAB_R2021a.app/extern/include/ src/kdtree.cc
or, you might be able to just compile without the path to the include files (which shouldn't be needed)
mex -v src/kdtree.cc
Both of the above worked for me once I set #include "mex.h" in the common file.
  1 件のコメント
Maia2022
Maia2022 2022 年 7 月 4 日
Hi,
Thanka a lot. For me, the solution is:
1) change to //#include "c:\matlab_rXXXXb\extern\include\mex.h" (XXXX beeing the Matlab version and I am with Windows)
2) go to /kdtree
3) mex -v src/kdtree.cc

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeMATLAB Compiler についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by