Calling C++ Shared Library Functions from MATLAB
古いコメントを表示
I have created a C shared library, loaded it using the loadlibrary(...) function, and successfully executed functions in it using the calllib(...) function. Everything works as expected. I am now attempting to do the same for a C++ API. Currently, I am using R2009a, because that is the only license my group has at the moment.
I would like to do the same for a C++ API. I converted by sample C API to a C++ API (simple switch at compile/link time), but when MATLAB loaded it, it was unable to resolve any of the symbols. I determined that this was due to the difference in signature mangling between C/C++. Does this mean that it is impossible to access a C++ shared library in the same way as accessing a C shared library? Is this simply a limitation of R2009a that has since been resolved in later versions?
If not, is adding a layer of abstraction a possibility? For example, have MATLAB link against a C API that forwards calls to a second C++ API? I tried a variation on this, but I had to replace the provided runtimes with runtimes that my C++ API require for it to even load. When I tried running, my code was never hit, and the return code from calllib(...) was 1 (when I explicitly returned 5 in my code).
1 件のコメント
Geoff Hayes
2015 年 1 月 8 日
James - how are you exposing your functions in the shared library (C++ version)?
回答 (0 件)
カテゴリ
ヘルプ センター および File Exchange で C Shared Library Integration についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!