Compile Single file in a project in netbeans

…衆ロ難τιáo~ 提交于 2021-01-01 06:44:12

问题


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:

  1. Under the Projects tab in the left, double-click on your project to show its contents.

  2. Double-click on the Source Files folder to show its contents

  3. Right-click on the earlier main file (most-likely main.cpp) and select Properties.

  4. Under the Item Configuration tab, check the Excluded from build option and click on Ok.

  5. Right-click on the Source Files folder, select New and click on C++ Main File. This will create a new main file in the same project.

  6. 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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!