How to Connect C++ to Matlab
How to Connect C++ to Matlab
I've tried to link between C++(Win32) and MATLAB(win64).I added the path under the VC++ directories and also added "libeng.lib libmx.lib libmex.lib libmat.lib" under linker>>input>.
but I got the error: error LNK2019: unresolved external symbol _engOpen referenced in function _main.
any idea to solve this problem?
C++ code:
#include <iostream>
#include "engine.h"
#include "mex.h"
#pragma comment (lib,"libmat.lib")
#pragma comment (lib,"libmx.lib")
#pragma comment (lib,"libmex.lib")
#pragma comment (lib,"libeng.lib")
using namespace std;
int main()
Engine *m_pEngine;
m_pEngine=engOpen("null");
return 0;
my MATLAB is 64bit and c++ is 32bit which are both running in my widows 64bit
– Morteza amin naji
Sep 5 '18 at 15:41
You could try changing the path for VC++ to target 64bit and see if that help you with the issue: How to Change VC++ to target 64bit
– Hasan Patel
Sep 5 '18 at 15:46
thanks a lot, it is solved now, but I got another error: as "the code execution cannot proceed because libmx.dll and libeng.dll was not found" what should I do now?
– Morteza amin naji
Sep 5 '18 at 15:56
1 Answer
1
The first thing to check if both Matlab and C++ are running on the same version (32bit or 64bit). You can change the settings on VC++ to run on 64 using this information from Microsfot: How to: Configure Visual C++ Projects to Target 64-Bit Platforms
For the Error related to libmx.dll was not found try the following:
Hope this helps; Cheers
I can find these files in MATLABROOT/bin/win32. How can I add this location to the system environmental?
– Morteza amin naji
Sep 5 '18 at 16:40
Thanks for contributing an answer to Stack Overflow!
But avoid …
To learn more, see our tips on writing great answers.
Some of your past answers have not been well-received, and you're in danger of being blocked from answering.
Please pay close attention to the following guidance:
But avoid …
To learn more, see our tips on writing great answers.
Required, but never shown
Required, but never shown
By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.
Have you check if your Matlab and C++ are running on the same platform (32bit or 64bit)?
– Hasan Patel
Sep 5 '18 at 15:31