1

I am trying to run one of the example codes from the CPP Mex Repository of Matlab R2021a in the VS2017 IDE. Specifically, I am running the phonebook.cpp one. I previously ran with no problems when compiling other solutions in VS2017 with the C Mex API following this guide. However, I get the following message when compiling phonebook.cpp:

Severity    Code    Description Project File    Line    Suppression State
Error   LNK2019 unresolved external symbol __imp_get_function_ptr referenced in function "int (__cdecl*__cdecl matlab::data::detail::resolveFunction<int (__cdecl*)(int,int,bool *)>(enum matlab::data::detail::FunctionType))(int,int,bool *)" (??$resolveFunction@P6AHHHPEA_N@Z@detail@data@matlab@@YAP6AHHHPEA_N@ZW4FunctionType@012@@Z) test    C:\Users\DuuMushishi\Documents\test.obj 1

I am not sure what library needs to be added or if the error is due to something else

  • See here.- https://stackoverflow.com/questions/12573816/what-is-an-undefined-reference-unresolved-external-symbol-error-and-how-do-i-fix?rq=1 – moi Sep 19 '21 at 19:49
  • Does this answer your question? [What is an undefined reference/unresolved external symbol error and how do I fix it?](https://stackoverflow.com/questions/12573816/what-is-an-undefined-reference-unresolved-external-symbol-error-and-how-do-i-fix) – moi Sep 19 '21 at 19:49
  • You should really be using the `mex` command to compile MEX-files. The guide you link misses a lot of things, including defining some preprocessor macros that specify what version of the API you want to use. The default API version is not the best option. If you want to build MEX-files “manually”, run `mex` with the `-v` switch so you can see how it calls the compiler and linker. That should give you a good indication of what else is needed. – Cris Luengo Sep 19 '21 at 22:34

1 Answers1

2

I fixed the issue. Turns out I had to include in additional dependencies "libMatlabDataArray.lib" (in my case, located in C:\Program Files\MATLAB\R2021a\extern\lib\win64\microsoft)