Wired MEX compiler error

10 views (last 30 days)
Denis Bethäuser
Denis Bethäuser on 11 Jan 2017
Commented: James Tursa on 2 Dec 2019
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 Comment
Vandana Ravichandran
Vandana Ravichandran on 19 Jan 2017
I am receiving the same error in MATLAB R2016b. However, the code compiled successfully in MATLAB R2016a. Can you try this in R2016a?

Sign in to comment.

Answers (1)

Vandana Ravichandran
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".
  3 Comments

Sign in to comment.

Community Treasure Hunt

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

Start Hunting!