Is main.cpp required?

I tried to compile the program with cmake, and I deleted my file main.cpp, which I just put into another file that indicated the name of my project (i.e. I just cut and pasted the main function into this one). The problem is that I received an main.cpperror not found and was not sure if there is a C++file known as main.cpp, or can I get a file with a different header that contains the main function instead?

Edit I should note that I deleted any specification in mainand recompiled this program.

+5
source share
4 answers

No, you do not need a file called main.cpp. You do not need a file containing main () unless you are creating an application. That is, if you were just building a function library or a stand-alone object file, you would not need main ().

+8
source

The name of the source file has nothing to do with the successful build of the program. All you need is the source file with the main function. Be that as it may, the name of the file as main.cppis just a programming practice, just to find where the main function is located.

+3
source

, , make

0

main.cpp.

0

All Articles