问题
I am using NetBeans Ide 8.2 on ubuntu 16
I am learning C and C++ programming hence the program i make are not related and when I try to create multiple file in a project the include multiple main() function which return error
error: multiple main function found
I want to create separate file for each program but I don't want to create separate project for all the program.
please suggest me a way & I am sorry for my language , I hope i am able to make you understand my problem.
回答1:
To have multiple main files in a single Netbeans project:
Under the
Projectstab in the left, double-click on your project to show its contents.Double-click on the
Source Filesfolder to show its contentsRight-click on the earlier main file (most-likely
main.cpp) and selectProperties.Under the
Item Configurationtab, check theExcluded from buildoption and click onOk.Right-click on the
Source Filesfolder, selectNewand click onC++ Main File. This will create a new main file in the same project.Now, when you build and run your project, it will compile the new main file, and the old one will be ignored.
Tip: It is a good idea to give unique names to the main files, to avoid name clashes.
来源:https://stackoverflow.com/questions/46862830/compile-single-file-in-a-project-in-netbeans