Hi all, I would like to use Matlab functions in my cpp project. I used command: mcc -W cpplib:liba -T link:lib odw, where odw is my Mfile. Matlab generated several files: liba.cpp liba.dll liba.exp liba.h liba.lib liba.export. I joined liba.cpp and liba.h to my Cpp, but it doesn't work. It doesn't see mclmcrrt.h and mclcppclass.h. Is it true that i have to join liba.dll too? I create my cpp project in QtCreator.
Thanks for responses! Jan

 채택된 답변

Kaustubha Govind
Kaustubha Govind 2012년 2월 14일

0 개 추천

You need to link against liba.lib, and add the directory containing liba.dll to the system PATH. See C++ Shared Library Example.

댓글 수: 3

jan
jan 2012년 2월 15일
I made it but in Visual Studio. But it doesn't work yet, i have problem with one thing which i found here:
[url]http://www.mathworks.com/support/solutions/en/data/1-2Q3TJ5/?solution=1-2Q3TJ5[/url]
I don't have mclmcrrt.lib in $MATLAB\extern\lib\win32\microsoft. It doesn't exist. I found this library in $MATLAB\extern\lib\win64\microsoft but then i have an error:
1>foowrap.obj : error LNK2019: unresolved external symbol _mclTerminateApplication_proxy referenced in function _main
It's not that library? which should i have link against my project?
Is any solution.
best regards,
Jan
Kaustubha Govind
Kaustubha Govind 2012년 2월 15일
It appears that you have 64-bit MATLAB (the win64 part of the directory path gave it away). Usually, Visual Studio projects are configured to produce a 32-bit binary by default. You need to configure it for an x64 target so it can link against the 64-bit MATLAB libraries.
jan
jan 2012년 2월 17일
It works, really thanks for help!
greetings
Jan.
btw. pretty photo :)

댓글을 달려면 로그인하십시오.

추가 답변 (1개)

Titus Edelhofer
Titus Edelhofer 2012년 2월 14일

0 개 추천

Hi Jan,
I would suggest to run the example from the MATLAB compiler section named "Libraries". Somewhere comes the call to mbuild to compile and link the application using the shared library. If you use the "-v" for the call to mbuild you will see what get's compiled and linked. Add the linked files to your project and it should work.
Titus

카테고리

도움말 센터File Exchange에서 C Shared Library Integration에 대해 자세히 알아보기

태그

질문:

jan
2012년 2월 14일

편집:

2013년 10월 13일

Community Treasure Hunt

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

Start Hunting!

Translated by