Code::Blocks之It seems that this file has not been built yet.

这两天在学习Objective-C,在Windows下面通过GNUstep和Code::Blocks的结合来进行代码的编辑和测试。关于GNUstep和Code::Blocks的环境的配置网上有很多教程,这里就不说了,配置好之后通过Code::Blocks进行工程的创建,然后测试第一个Hello World程序,没有任何问题,具体流程如下:

File--->New--->Project--->Console application,建立如下图所示的工程:

Code::Blocks之It seems that this file has not been built yet._第1张图片

然后将该工程中默认生成main.c改成HelloWorld.m,然后再其中输入代码如下:

Code::Blocks之It seems that this file has not been built yet._第2张图片

然后进行进行Build and run,得到执行结果如下:

Code::Blocks之It seems that this file has not been built yet._第3张图片

此时我想将HelloWorld.m文件删除,然后重新添加一个新的Objective-C文件test.m进行测试,如下图:

Code::Blocks之It seems that this file has not been built yet._第4张图片

然后进行Rebuild,当执行Run时,出现如下问题:

Code::Blocks之It seems that this file has not been built yet._第5张图片

在网上搜了一下这个问题,大部分都是说环境配置问题,但我这里肯定不是环境问题,因为前面已经运行成功了,然后我仔细查看了一下Compile和Build的输出信息:

Compile的输出信息:
Nothing to be done (all items are up-to-date).

Build的输出信息:
-------------- Build: Debug in objcTest (compiler: GNUstep GCC Compiler)---------------

Linking stage skipped (build target has no object files to link)
Nothing to be done (all items are up-to-date).
由上可知,compile什么也没干,Build也没有找到目标文件进行link,简直无语了,怎么会找不到呢,经过多次测试然后我就发现,最开始的test.m 和HelloWorld.m的颜色不一样,如下图:

Code::Blocks之It seems that this file has not been built yet._第6张图片

test.m是显示为灰色的,然后查看两个文件的属性,发现test.m的compile file和 link file选项都没有被选中,如下图所示,这也就是为什么test.m无法编译链接执行的原因。

Code::Blocks之It seems that this file has not been built yet._第7张图片

所以将这两个选项选中,就可以进行编译链接了。得到如下结果:

Code::Blocks之It seems that this file has not been built yet._第8张图片

至于为什么Cold::Blocks会将.m文件设置成不可Compile和Link,这应该是我们在建立工程时,该工程项目所支持哪些文件可以用来进行编译链接所决定的。当你添加一个新的工程无法识别的文件类型时,默认情况下,该文件是不可以被编译的。


Mar. 11, 2014 @801

你可能感兴趣的:(Soft,Configuration)