Calling a C++ function from a shared library .so file
조회 수: 8 (최근 30일)
이전 댓글 표시
Hi,
I would like some advices on how to approach a project. I have create a C++ code that extensively uses another library (CGAL). Now, I would like to call some function from this shared library, from Matlab, just like how I would call a Matlab function.
My question is, what is the best way to do this. I did a quick research and it comes up with this and this. The first link seems to be what I am looking, but I have no idea what Matlab interface file is, and there seems to be not a clear answer. The second link shows how to create a MEX file, which I am not sure if that's what I want, as I already made the shared library and not sure if I want to modify it.
Any suggestion?
댓글 수: 0
답변 (1개)
Dinesh Yadav
2020년 3월 6일
Hi,
In simulink we can call C++ shared library functions using S-functions. Let main s-function file be main.cpp and shared library file be sharedObject.so. Compile the files and create a mex executable by calling the command
mex main.cpp -Ipath_to_.so_file)/sharedObject.so
Call the generated mex file in s-function block in simulink.
Hope this workaround using simulink works for you. For more information on s-functions type sfundemos in MATLAB command promt and see existing examples.
I am attaching a document containing a sample program.
댓글 수: 0
참고 항목
카테고리
Help Center 및 File Exchange에서 Troubleshooting in MATLAB Compiler SDK에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!