How to include a multi-file C++ library to S-function builder?

28 ビュー (過去 30 日間)
Gabriel Droguett
Gabriel Droguett 2020 年 5 月 30 日
コメント済み: Gabriel Droguett 2020 年 6 月 11 日
Dear all, nowadays I´m facing a problem with S-function builder block. I need to include the libtorch library in order to run it on a real-time platform, the problem is The library is made up of a lot of files thats includes another files. I know that if I want to include external libraries I should use """ instead of <> to include the libraries at the "Libraries" Tab in S-function builder, however the file that I include, includes other files but using <> and those files calls others files using <> and so on. There is a way to include the whole library in the S-function?
This is my workspace, the alreay generated mex and wrapper are only a test, no included libraries on it.
These are the first header files, I need to include "script.h" in order to initialize the objects of the library, each of the includes inside script.h includes more .h files :C. I can include "script.h", but it fails when simulink tryes to include the other files:
There is a way to include the whole library? Please help.

回答 (1 件)

Dinesh Yadav
Dinesh Yadav 2020 年 6 月 2 日
Hi Gabriel,
I think the above error is more related to the path. If you have included the "script.h" it includes the internal include files as well provided you have set the path (i.e MATLAB knows where to find the internal include files as well, see link). Also I couldnt help but notice the mismatched backward and forward slashes in the file path shown in the error.
  1 件のコメント
Gabriel Droguett
Gabriel Droguett 2020 年 6 月 11 日
Thanks Dinesh, the backward and forward slashes are not a problem. However, the includes files in script.h are invokedwith <filename.h> whats matlabs searchs for in some other place that I don´t know where is, even if I include the script with <torch/script.h> it doesn´t work. If I DO:
//Library object source files pane
LIB_PATH C:/CppIncludes/libtorch/include/
SRC_PATH C:/CppIncludes/libtorch/include/
//includes pane
#include <math.h>
#include <torch/script.h>
It doesn't work. How I can include the files? I think even I try with "" to incloude the files it will be the same because the script.h files and the another inside the library folder include the files using <>.

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

カテゴリ

Help Center および File ExchangeAuthor Blocks Using S-Function Builder についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by