Reputation: 509
I'm EXTREMELY new to Visual Studio and C++ in general and I wanted to run a file within a project with other files in it. The file contains the simple code to print "Hello, World!". When I run this file, an error claims that main() has been defined in a .obj file which contains simple addition code as well. These two files are in the same project.
For some reason (maybe because of my ignorance) it seems nobody else has this problem.
Here's the error:
Error LNK2005 _main already defined in addition.obj
Upvotes: 1
Views: 726
Reputation:
C++ can only have one main()
per program as the compiler says.
You need Visual Studio to treat the files as separate programs. To do that you need to create separate projects for each of the files and compile them separately.
Upvotes: 1