Wired MEX compiler error

조회 수: 5 (최근 30일)
Denis Bethäuser
Denis Bethäuser 2017년 1월 11일
댓글: James Tursa 2019년 12월 2일
Hey there, I tried to compile the example program for the HCRF library of Yale Song. The source can be found here: HCRFlight. I use Ubuntu 16.04, Matlab R2016b and the g++ 4.7 as commented by Mathworks. During the compilation of the library I get this strange compiler error:
Error using mex /usr/share/MATLAB/R2016b/extern/version/cpp_mexapi_version.cpp: In Funktion »void mexfilerequiredapiversion(unsigned int*, unsigned int*)«: /usr/share/MATLAB/R2016b/extern/version/cpp_mexapi_version.cpp:6:21: Fehler: »MX_TARGET_API_VER« wurde in diesem Gültigkeitsbereich nicht definiert
Which basically means that "MX_TARGET_API_VER" is not defined in this scope. As you can see from the path, the error occurs in a file from Mathworks. How may I solve this error? I’m kinda confused by the error message and I haven’t found anything on google.
  댓글 수: 1
Vandana Ravichandran
Vandana Ravichandran 2017년 1월 19일
I am receiving the same error in MATLAB R2016b. However, the code compiled successfully in MATLAB R2016a. Can you try this in R2016a?

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

답변 (1개)

Vandana Ravichandran
Vandana Ravichandran 2017년 1월 19일
The mex compilation is successful in MATLAB R2016a. However, in MATLAB R2016b we receive an error - "MX_TARGET_API_VER was not declared in this scope"
The problem is because of the "matrix.h" file present in the library in the folder hCRFlight/lib/matlab/include/
This is a custom version of "matrix.h" which looks like a revision of "matrix.h" shipped with MATLAB R2016a.
In MATLAB R2016b, some MEX related changes were made to "matrix.h". The MEX command fails in R2016b because the revised R2016a version of "matrix.h" is not compatible with the official R2016b version of "matrix.h".
In order to make the package work with MATLAB R2016b:
a. You may revise the custom "matrix.h" to include all the contents from the R2016b version of "matrix.h".
b. Refactor the code to always include the default "matrix.h" shipped with MATLAB R2016b and use a different header file to contain other definitions from the custom "matrix.h".
  댓글 수: 3
Ashley Ware
Ashley Ware 2019년 12월 1일
I am also having this issue. Were you able to find a solution?
James Tursa
James Tursa 2019년 12월 2일

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

카테고리

Help CenterFile Exchange에서 Write C Functions Callable from MATLAB (MEX Files)에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by