How to use so file in Matlab?

24 ビュー (過去 30 日間)
Sungmin Jo
Sungmin Jo 2017 年 12 月 28 日
コメント済み: he zhang 2019 年 11 月 19 日
1. Can I use so file in Windows matlab? If yes, How to use it? 2. Can I use so file in Linux matlab? If yes, How to use it?
I want to use .so file in matlab. I made so file from c++ in linux. Can I use that so file in matlab?
I want to use it in windows matlab, but if it impossible, I can use matlab in linux.

回答 (1 件)

Harish Ramachandran
Harish Ramachandran 2018 年 1 月 2 日
Hello Sungmin,
If I understand correctly, you have a .so file along with C++ code which needs to be run in MATLAB. If that is the case, you can use Mex files in order to call your C++ code (along with the shared .so library file as a dependency) from the MATLAB command line. This is independent of the OS. You need to setup a supported mex C++ compiler and write a gateway function in C++.
After completing the above steps, you can proceed to compile the C++ code with the .so file.
mex gateway.cpp source.cpp file.so
  3 件のコメント
he zhang
he zhang 2019 年 11 月 19 日
Hi,
i encountered a problem on apply .so file:
firstly , i use mex command to compile mex function:
mex -v MexTest3.cpp libDemo3.so
and the information shows mex completed successfully. but then
when i use MexTest3() to apply mex function, it shows:
libDemo3.so: cannot open shared object file: No such file or directory.
it seems like .so file is not included or not in included path, so i did a test:
i create a main.cpp to apply libDemo3.so and it works.:
g++ mian.cpp -L. -lDemo3 -o main
So, something seems to be wrong with my matlab Mex. Do you have any suggestions? Thanks.

サインインしてコメントする。

タグ

製品

Community Treasure Hunt

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

Start Hunting!