I have a simulink model with a c++ s-function. This s-function needs access to a lot of (>50) classes. Each class is consists of a header (.h) and a source (.cpp) file. I have also divided my code into multiple directories:
root
-sfun.cpp
-folder1
--file1.h
--file1.cpp
--file2.h
--file2.cpp
-folder2
--file3.h
--file3.cpp
...
For the compilation of the s-function I am using 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 this gets very long and ugly with more and more files because I need to specify each header folder and earch source file separately. Is there a better way to create a mex file that needs access to lots of source files?
I have the following ideas, but I am not sure what could be the correct and easiest way:
Add all header and source files (fileX.h/ fileX.cpp) to an visual studio project and compile them to a *.lib file. Then compile only the sfun.cpp with the mex tool and provide access to the *.lib file
Move all header and source files into one directory. This would shorten the command line as follows:
mex -outdir bin sfun.cpp file1.cpp file2.cpp file3.cpp
Making everything inline so that there is no need for a source file. (very ugly solution)
Is there some kind of a makefile for the mex compiler?
Include not only the header files but also the source files via a #include directive.
At the moment I am not convinced of any of these ideas and I would appreciate any help.
Thanks
Edit1: One annotation: This project should be ported to a dspace pc in a later stage. Do I need to consider something special in this case?