Making cpp code from Mfile.

4 Ansichten (letzte 30 Tage)
jan
jan am 14 Feb. 2012
Bearbeitet: Matt J am 13 Okt. 2013
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

Akzeptierte Antwort

Kaustubha Govind
Kaustubha Govind am 14 Feb. 2012
You need to link against liba.lib, and add the directory containing liba.dll to the system PATH. See C++ Shared Library Example.
  3 Kommentare
Kaustubha Govind
Kaustubha Govind am 15 Feb. 2012
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 am 17 Feb. 2012
It works, really thanks for help!
greetings
Jan.
btw. pretty photo :)

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (1)

Titus Edelhofer
Titus Edelhofer am 14 Feb. 2012
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

Kategorien

Mehr zu C Shared Library Integration finden Sie in Help Center und File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by