Wired MEX compiler error
10 views (last 30 days)
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.
Vandana Ravichandran on 19 Jan 2017
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".