I would like to use a c-program in Matlab. It consists of several c-files. I have read several approaches, and also most of the examples I see is to write the c-code in a mex wrapper and compile it. What I want is to include these c-files in the mex file, and compile and link it. I also read about compiling them separately with a c-compiler and load the library. Does anyone have a clear set of instructions or directions on what would be the best way to go about this? Thanks a lot!

 採用された回答

Philip Borghesani
Philip Borghesani 2015 年 6 月 30 日

0 投票

If these c files are already a library of functions and you wish to use more then one of them from MATLAB then make a shared library (dll) and use loadlibrary.
If these c files should be turned into a single function to be called by MATLAB or still need some work to combine together into something useable then I recommend creating a mex file.

3 件のコメント

Jason
Jason 2015 年 6 月 30 日
Hi Philip, thank you for your help. I would prefer to include all the headers in the mex file and just compile the mex file. Would that work? How do I go about compiling this mex file with all these separate .c files? Is there an example somewhere? I am sorry, I don't really have programming background.
Philip Borghesani
Philip Borghesani 2015 年 7 月 1 日
There are examples in the documentation for mex on building a mex file from multiple c files. How you should do it in your case is beyond the scope of an answers question. You will probably need to learn some programming elsewhere or get help from someone familiar with c.
Jason
Jason 2015 年 7 月 1 日
Thanks a lot for your pointers!

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

その他の回答 (0 件)

カテゴリ

ヘルプ センター および File ExchangeMATLAB Compiler についてさらに検索

質問済み:

2015 年 6 月 30 日

コメント済み:

2015 年 7 月 1 日

Community Treasure Hunt

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

Start Hunting!

Translated by