在NetBeans中的项目中编译单个文件 [英] Compile Single file in a project in netbeans
问题描述
我正在 ubuntu 16
我正在学习 C 和 C ++ 编程,因此我制作的程序不相关,并且当我尝试在项目中创建多个文件时,会包含 multiple main()函数会返回错误
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.
推荐答案
要在一个Netbeans项目中具有多个主文件:
To have multiple main files in a single Netbeans project:
-
在左侧的
Projects
标签下,双击您的项目以显示其内容.
Under the
Projects
tab in the left, double-click on your project to show its contents.
双击 Source Files
文件夹以显示其内容
Double-click on the Source Files
folder to show its contents
右键单击较早的主文件(最可能是 main.cpp
),然后选择 Properties
.
Right-click on the earlier main file (most-likely main.cpp
) and select Properties
.
在 Item Configuration
标签下,选中 Excluded from build
选项,然后单击 Ok
.
Under the Item Configuration
tab, check the Excluded from build
option and click on Ok
.
右键单击 Source Files
文件夹,选择 New
,然后单击 C ++ Main File
.这将在同一项目中创建一个新的主文件.
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.
现在,当您构建并运行项目时,它将编译新的主文件,而旧的主文件将被忽略.
Now, when you build and run your project, it will compile the new main file, and the old one will be ignored.
提示:最好为 main
文件赋予唯一的名称,以避免名称冲突.
Tip: It is a good idea to give unique names to the main
files, to avoid name clashes.
这篇关于在NetBeans中的项目中编译单个文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!