Compiling a C/C++ function with external dependencies
3 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
There is a cross-platform library called LCM, the lightweight communication and marshaling protocol, which provides some cool interprocess communication capabilities. I have C functions that can publish and subscribe to LCM channels. I want to get these functions into a Simulink block so that I can communicate with a running model from other processes. These functions, of course, have a dependency on the LCM library. I can compile this program in my C IDE with a cmakelists file - what is the most straightforward way to compile this program for Matlab?
Réponses (1)
Rutuja Shirali
le 3 Sep 2015
Hi Ryan,
We can accomplish calling C/C++ code from MATLAB in the following ways:
- We can directly call C library finctions from MATLAB by loading the library using the "loadlibrary" function and calling functions from the library using "calllib" function. More information about this can be found here:
- Moreover, we can write a MEX-file to call C/C++ functions and then build it. While building we can use the "-L" and "-l" flags to specify external libraries. More information about MEX-file creation and the "mex" function can be found here:
I hope this helps with your issue. If this is not what you are expecting I would suggest contacting MathWorks Technical Support with more clarification on your workflow.
Thanks!
Rutuja
0 commentaires
Voir également
Catégories
En savoir plus sur Call C++ from MATLAB dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!