Why do I receive an "LNK2019: unresolved external symbol _engOpen referenced in function" error when I compile my C++ code that calls the MATLAB engine API in Microsoft Visual Studio .NET?

7 ビュー (過去 30 日間)
I have created a C++ project in Microsoft Visual Studio .NET which uses the C MATLAB engine API's. I included the engine.h file that is located in the $MATLABROOT/extern/include (where $MATLABROOT is the MATLAB root directory on my machine, as returned by typing
matlabroot
at the MATLAB command prompt.)
When I build the project I get error messages of the form:
ERROR: LNK2019: unresolved external symbol _engOpen referenced in function
LNK2019: unresolved external symbol _engClose referenced in function

採用された回答

MathWorks Support Team
MathWorks Support Team 2023 年 2 月 20 日
編集済み: MathWorks Support Team 2023 年 4 月 16 日
This error occurs when you do not link the required static library, libeng.lib which is located in $MATLAB/extern/lib/win32/microsoft. (where $MATLAB is the MATLAB root directory on your machine, as returned by typing
matlabroot
at the MATLAB command prompt.)
In order to link the required static library, perform the following steps: (these steps may differ by Microsoft Visual Studio version)
1. Select the project in the tree and then select Project->Properties menu item to open the 'Property pages' window.
2. Here select the 'Linker' node that is under the 'Configuration Properties' node. Add the $MATLAB/extern/lib/win32/microsoft directory to the 'Additional Library Directories' field.
3. Select the 'Input' node under the 'Linker' node. Add the libeng.lib file in the 'Additional Dependencies' field.
4. Build the project.
Other modifications to your settings may also be required, for general instructions on configuring Microsoft Visual Studio, please see the related solution below.
https://www.mathworks.com/matlabcentral/answers/96120-how-do-i-configure-my-ide-to-compile-matlab-engine-applications

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeC Shared Library Integration についてさらに検索

製品

Community Treasure Hunt

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

Start Hunting!

Translated by