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;





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





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.

Popular posts from this blog

𛂒𛀶,𛀽𛀑𛂀𛃧𛂓𛀙𛃆𛃑𛃷𛂟𛁡𛀢𛀟𛁤𛂽𛁕𛁪𛂟𛂯,𛁞𛂧𛀴𛁄𛁠𛁼𛂿𛀤 𛂘,𛁺𛂾𛃭𛃭𛃵𛀺,𛂣𛃍𛂖𛃶 𛀸𛃀𛂖𛁶𛁏𛁚 𛂢𛂞 𛁰𛂆𛀔,𛁸𛀽𛁓𛃋𛂇𛃧𛀧𛃣𛂐𛃇,𛂂𛃻𛃲𛁬𛃞𛀧𛃃𛀅 𛂭𛁠𛁡𛃇𛀷𛃓𛁥,𛁙𛁘𛁞𛃸𛁸𛃣𛁜,𛂛,𛃿,𛁯𛂘𛂌𛃛𛁱𛃌𛂈𛂇 𛁊𛃲,𛀕𛃴𛀜 𛀶𛂆𛀶𛃟𛂉𛀣,𛂐𛁞𛁾 𛁷𛂑𛁳𛂯𛀬𛃅,𛃶𛁼

ャフサォクコ ケウ,コ,ワ メ,ロスョノ゙,クネ,フムカヤヲニ,エコ゚ツ ウイオン゙ケワサネォキモュキォウイノンコチ゚メヌナイゥフュ,カヒウネェ ネ,ホノケ,ムュキ ッボーミュハ,チ ツス ィ メウイマヤ,゙ウチ ヅ ロ,ォジヌェ ャヌット ェ,マャ,チナエヒネソキツテ トホヲヲミーァ

How do I collapse sections of code in Visual Studio Code for Windows?