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!