How do I use a matlab shared library without building the main executable with mbuild?

8 ビュー (過去 30 日間)
Tony Kirke
Tony Kirke 2017 年 2 月 16 日
編集済み: Tony Kirke 2017 年 2 月 21 日
Hi I'm able to build the shared library fine. However,I'd like to use it in another program and just want to include the header and reference the .dylib file. However, whenever I try that I run into all sorts of issues such as either "Illegal Instruction 4" or Missing .plist file. The latter can be solved but I don't know how to debug/fix the illegal instruction. I don't want to use mbuild because my executable requires a very large number of files with various build options, etc and it's not feasible to build with mbuild. I tried to use mbuild to just build the top level and link in various libraries but also had issues with that. Can Mathworks provide a way to use a simple shared library without requiring mbuild?

回答 (2 件)

Sangeetha Jayaprakash
Sangeetha Jayaprakash 2017 年 2 月 21 日
I am assuming that you have used the "mcc" MATLAB command to build the shared library from MATLAB(.m) files, and you would like to use this shared library in a C++ project of your own.
You can compile the generated shared library like any other shared C library, using 'gcc'. Refer this link, for steps on achieving this on UNIX:
Similarly, you can achieve the same on OS X.
Also, ensure that you add the following OS X platform-specific folders to your dynamic library path (DYLD_LIBRARY_PATH variable):
  • matlabroot/runtime/maci64
  • matlabroot/bin/maci64
  • matlabroot/sys/os/maci64

Tony Kirke
Tony Kirke 2017 年 2 月 21 日
編集済み: Tony Kirke 2017 年 2 月 21 日
Thanks. When I try to follow this I get
The -t switch is no longer supported; the Compiler no longer generates C/C++ source code for MATLAB functions (it generates wrapper functions instead, see the documenation for -W).
The -L switch is no longer supported; the target (-T) and wrapper (-W) switches determine the language of the generated code.
The -h switch is no longer supported; the MATLAB Compiler detects MATLAB file dependencies automatically. But see also the documentation for the -a switch.
No supported compiler or SDK was found. For options, visit http://www.mathworks.com/support/compilers/R2016a/maci64.html. >>

カテゴリ

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