- Double-check that the library directories and library names are spelled correctly in the Visual Studio project properties. Make sure there are no typos or extra spaces.
- Check that the libraries are in the directories you specified in the project properties. If they are not, you may need to download and install the MATLAB Runtime or MATLAB Compiler Runtime libraries.
- Try adding the MATLAB library directories to your system's PATH environment variable. To do this, go to Control Panel > System > Advanced System Settings > Environment Variables, and add the MATLAB library directories to the PATH variable.
- Make sure you are using the correct version of the MATLAB libraries. If you are using a different version of MATLAB than R2019a, you may need to update your libraries or use the correct version of MATLAB.
- Check that the functions you are using from the libmat and libmx libraries are actually available in those libraries. Sometimes, different versions of the libraries may have different function names or may not have certain functions at all.
- Try including the header files for the libmat and libmx libraries in your C++ code. This can help ensure that the function definitions are properly linked with your code.
Getting "LNK2019 unresolved external symbol _ ..." errors when compiling C++ program linked to MATLAB libraries
11 次查看(过去 30 天)
显示 更早的评论
I'm writing a C++ program to read in data files with code I already have and ouput them to *.mat files. The program uses the following:
from libmx.lib
* mxlsFromGlobalWS
* mxGetString
* mxGetPr
* mxGetNumberOfDimensions
* mxDestoryArray
* mxCreateString
* mxCreateDoubleMatrix
from libmat.lib
* matPutVariable
* matPutVariableAsGlobal
* matOpen
* matGetVariable
* matClose
I went to properties > Linker > General and put into 'Additonal Library Directories' and added:
C:\Program Files\\MATLAB\\R2019a_NMCI\\extern\\lib\\win64\\microsoft
I went to properties > Linker > Input and put into 'Additional Dependencies' and added:
libmx.lib;libmat.lib
Visual Studio made it into this, but I think it's the same thing.
libmx.lib;libmat.lib;%(AdditionalDependencies)
And yet, I am still getting the dreaded LNK2019 Error for the abover functions from the libmat and libmx libraries. What else should be done???
0 个评论
回答(2 个)
Aishwarya Shukla
2023-3-31
The LNK2019 error indicates that the linker is unable to find the definitions for the functions you are trying to use from the libmat and libmx libraries. This error can occur if the libraries are not linked properly or if the libraries are not located in the correct directories.
Here are some additional steps you can try:
I hope these suggestions help you resolve the LNK2019 error and successfully link your program with the libmat and libmx libraries.
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!