Failed to Initialize MATLAB R2023b Runtime Library in Visual Studio 2019 C++ Project
14 次查看(过去 30 天)
显示 更早的评论
I generated a C shared library type DLL for a custom function using the MATLAB Library Compiler and created a console C++ project in Visual Studio 2019 to call the DLL function and continue development. However, when initializing the DLL function, it reports a failure. I have set the PATH in the system environment variable to D:\Program Files\MATLAB\MATLAB Runtime\R2023b\bin\win64, and I have also set the include and library directories in Visual Studio 2019, and entered as many MATLAB runtime libraries as possible in the linker: mclmcr.lib; mclmcrrt.lib; libmat.lib; libmex.lib; libmx.lib; along with the custom .lib file. Why is the runtime library initialization still failing? My MATLAB version is R2023b, the compiler version is 23.2, and the runtime library version is 23. What could be causing the runtime library initialization to fail?
回答(1 个)
Harsh
2024-8-27
From what I can gather, you are trying to set up MS Visual Studio along with MATLAB for C++ development in windows and are facing issues in the process.
Here’s how you can achieve the same:
- Go to the properties of your project node.
- Make sure the platform is set to x64:
- Under C/C++ > General, add the following directory to the Additional Include Directories field:
C:\Program Files\MATLAB\MATLAB Runtime\R2023b\extern\include
- Under Linker > General, add the following directory to the Additional Library Directories field:
C:\Program Files\MATLAB\MATLAB Runtime\R2023b\extern\lib\win64\microsoft
- Under Linker > Input, add the following libraries to the Additional Dependencies field.
Add delayimp.lib; libMatlabCppSharedLib.lib; libMatlabDataArray.lib along with mclmcr.lib; mclmcrrt.lib; libmat.lib; libmex.lib; libmx.lib;
After which you can include the relevant headers and the build in release and x64.
Refer the following MathWorks document to learn more:
I hope this helps, thanks!
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 C Shared Library Integration 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!