I just started learning Openframeworks and while I can run my code without problems, I don’t understand one thing:
When I create a new project with the ProjectGenerator there are only three files in the src directory:
main.cpp
ofApp.h
ofApp.cpp
Both, main.cpp and ofApp.h include a non-existing(?)main.h. Why is it not there?
Also I don’t have to include standard libraries like <iostream>, it seems they are already included. Are those included in this hiding main.h file?
It’s not hidden. it is included in Header Search Paths in Build Settings.
The path is as following. ../../../libs/openFrameworks/ofMain.h
And yes, standard libraries are already included.
Thank you cuinjune!
I already thought something like this, but couldn’t find a specific line of code pointing this out.
Just for a better understanding (I’m also not an expert in build systems yet), how exactly does it work, that there is a generic main.h used. And what are the advantaged/disadvantages of this approach?
If you add the library as search paths, you don’t have to copy all the files into your project whenever you create a new one. So your project folder can separately exist from the library and only have the project specific files in it.
main.cpp doesn’t have or need a header, a cpp only needs a header in order to call the functions in it from other files but since main.cpp only contains the main function which is only called by the operating system itself it doesn’t need a header