Matlab C ++ S-Function with multiple source files

I have a simulink model with C ++ s function. This s-function needs access to many (> 50) classes. Each class consists of a header (.h) and a source file (.cpp). I also split my code into several directories:

root
-sfun.cpp
-folder1
--file1.h
--file1.cpp
--file2.h
--file2.cpp
-folder2
--file3.h
--file3.cpp
...

To compile the s function, I use the mex function:

mex -Ifolder1 -Ifolder2 -outdir bin sfun.cpp folder1/file1.cpp folder1/file2.cpp folder1/file3.cpp

( http://de.mathworks.com/help/matlab/ref/mex.html )

But it gets very long and ugly with lots of files, because I need to separately specify each header folder and source earch file. Is there a better way to create a mex file that needs access to a lot of source files?

I have the following ideas, but I'm not sure what might be the right and simple way:

  • (fileX.h/fileX.cpp) *.lib. sfun.cpp mex *.lib.

  • . :

    mex -outdir bin sfun.cpp file1.cpp file2.cpp file3.cpp
    
  • , . ( )

  • - make mex-?

  • , #include.

, .

Edit1: : dspace . - ?

+4

All Articles