关于Code::Blocks建立工程时出现“file not recognized: File format not recognized”“it seems that this project...

    今天,用codeblocks建立完一个工程后,编译时出现了"file not recognized: File format not recognized"的信息

如下图:

点击运行,出现:

It seems that this project has not been built yet.

如下图:
关于Code::Blocks建立工程时出现“file not recognized: File format not recognized”“it seems that this project..._第1张图片

网上搜的解决办法都不行,比如什么在.h文件(头文件)右键选择Option->Compile file、Link file前面勾去掉,重新编译可运行。我试了一下,出现下面的错误:
Linking stage skipped (build target has no object files to link)

Nothing to be done (all items are up-to-date).

关于Code::Blocks建立工程时出现“file not recognized: File format not recognized”“it seems that this project..._第2张图片

后来,我发现了可能错误的原因:我们点击编译会出现一个预编译的头文件(如student.h.gch),但在我的编译器中并不

支持或者说是兼容这种预编译文件,所以链接失败了。

解决方案有两种(前提确定不是因为你的编译器路径设置的问题):

方案1

(1)在你所建的工程,右键选择"Propties"。

关于Code::Blocks建立工程时出现“file not recognized: File format not recognized”“it seems that this project..._第3张图片


(2)选择"Build targets"的卡项,将"Build target files"(目标文件)(也就是你所建立的源文件和头文件)的复选框全部勾上。点击OK.
关于Code::Blocks建立工程时出现“file not recognized: File format not recognized”“it seems that this project..._第4张图片


(3)接下来点击编译运行,完全OK了。
关于Code::Blocks建立工程时出现“file not recognized: File format not recognized”“it seems that this project..._第5张图片

注意:头文件的Option->Compile file、Link file不用勾选.
关于Code::Blocks建立工程时出现“file not recognized: File format not recognized”“it seems that this project..._第6张图片


方案2:

备份代码,重新建立工程。

(1)注意下面的步骤(全部勾选上)

关于Code::Blocks建立工程时出现“file not recognized: File format not recognized”“it seems that this project..._第7张图片

(2)创建.cpp/.c源代码文件时,将他们勾选上,如下图

关于Code::Blocks建立工程时出现“file not recognized: File format not recognized”“it seems that this project..._第8张图片

(3)建立头文件也一样。

关于Code::Blocks建立工程时出现“file not recognized: File format not recognized”“it seems that this project..._第9张图片
全部弄好后,点击编译运行,完全OK了。

你可能感兴趣的:(Codeblocks)