How to run C codes in Matlab on linux?

2 ビュー (過去 30 日間)
Haizheng Li
Haizheng Li 2020 年 11 月 6 日
コメント済み: Haizheng Li 2021 年 2 月 6 日
Hello everyone! I'm working on Linux system. There are some C codes written on windows and used in matlab with mex, but it seems that mex is not available on Linux... Could anyone tell me how can I run C codes with matlab on Linux? Thanks a lot.

回答 (1 件)

Aghamarsh Varanasi
Aghamarsh Varanasi 2020 年 11 月 9 日
Hi,
C code can be compiled in Linux using the mex command. Ensure that you have gcc installed in your machine. If you are compiling the C code for the first time, run the following command to see which compiler is used to compile the C code.
mex -setup
You can also refer to the following example to Create C Source MEX Files.
  2 件のコメント
Haizheng Li
Haizheng Li 2020 年 11 月 9 日
haha thank you... I have solved this with dynamic linked library and it already works XD I will try the method you suggusted and thank you all the way
Haizheng Li
Haizheng Li 2021 年 2 月 6 日
sorry to bother another time... due to some reasons I gave up using shared library and need to use MEX files. I just followed the tutorial you gave me and it just doesn't work... I just ran the following command:
mex arrayProduct.c
but there is was an error:
Error using mex
/usr/bin/ld: cannot find -lstdc++
collect2: error: ld returned 1 exit status
could you please give me some help?

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

カテゴリ

Help Center および File ExchangeWrite C Functions Callable from MATLAB (MEX Files) についてさらに検索

タグ

製品

Community Treasure Hunt

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

Start Hunting!

Translated by