简体   繁体   English

XCODE 错误:未构建新文件

[英]XCODE error: new file not built

So first I made a new project by going to File> OS X > Command Line Tool and chose C as the language.所以首先我通过转到文件> OS X> 命令行工具创建了一个新项目,并选择了 C 作为语言。 This is what I got:这是我得到的:

在此处输入图片说明

Then I made a new C file called program.c:然后我创建了一个名为 program.c 的新 C 文件: 在此处输入图片说明

Then I pressed run.然后我按下了运行。 It didn't build successfully:它没有成功构建:

在此处输入图片说明

However, when I deleted the first default file (main.c) and then pressed run program1.c....it built successfully.但是,当我删除第一个默认文件 (main.c) 然后按下 run program1.c.... 它构建成功。

My problem: Why can't I have several files under the same project and run them successfully?我的问题:为什么我不能在同一个项目下有多个文件并成功运行它们?

You can't have 2 main functions你不能有两个主要功能

Edit: each c program has to contain only one main function.编辑:每个 c 程序必须只包含一个主要功能。 Other files of that program can not implement another main function.该程序的其他文件不能实现另一个主要功能。

Because you will have the main function declared in both files.因为您将在两个文件中声明 main 函数。 I do not know how to tell XCode to build two separate applications..我不知道如何告诉 XCode 构建两个单独的应用程序..

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 错误:Xcode上没有这样的文件或目录 - Error: No such file or directory on Xcode 在Xcode中使用C读取文件时出错 - Error reading file in C in Xcode 无法运行新的主文件Xcode - Can't Run New Main File Xcode C-无法从Xcode创建新的.txt文件 - C - Can't create new .txt file from Xcode macos是内置clang编译器还是内置xcode ide? - Does macos come built in with the clang compiler or is built in with the xcode ide? 错误:文件是为不受支持的文件格式构建的,这不是正在链接的体系结构 (x86_64) - Error: file was built for unsupported file format which is not the architecture being linked (x86_64) 在XCode中复制目标时,新文件中的更改仍会出现在旧文件中 - When duplicating a target in XCode, changes in the new file still also appear in the old file 在Xcode,mac中找不到gmp.h文件错误 - gmp.h file not found error in Xcode, mac XCode 5.1中的“找不到'portaudio.h'文件”错误 - “'portaudio.h' file not found” error in XCode 5.1 在 Windows 7 上从 Java 启动 CYGWIN 构建的可执行文件失败,并显示“加载共享库时出错:?:没有这样的文件或目录” - Launching CYGWIN-built executable from Java on Windows 7 fails with "error while loading shared libraries: ?: No such file or directory"
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM