日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當(dāng)前位置: 首頁 > 编程语言 > c/c++ >内容正文

c/c++

codeblocks编译出错问题的解答!(编译c++ 或者c程序)

發(fā)布時間:2024/3/12 c/c++ 30 豆豆
生活随笔 收集整理的這篇文章主要介紹了 codeblocks编译出错问题的解答!(编译c++ 或者c程序) 小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.

典型錯誤:

execution of 'mingw32-g++.exe ……faile!

codeblocks cannot exec `cc1plus': No such file or directory

出現(xiàn)這樣的錯誤,都是因為編譯器沒安裝成功,或者沒有設(shè)置好!


從設(shè)置過程就可以知道有沒有安裝g++編譯器。

設(shè)置方法:Settings——Compiler…

一般默認(rèn)compiler是GNU GCC Compiler


點進Toolchain executables,下面三項中,最好點進去重新選擇一遍!?


如果沒有安裝mingw(gcc、g++)編譯器,選進去的時候就找不到mingw32-g++.exe。

如此就說明沒有安裝mingw,可以單獨下載mingw(http://download.csdn.net/detail/jingmiaa/9588535),安裝,然后重新設(shè)置,在mingw安裝目錄下可以找到mingw32-g++.exe。

(c++代碼,編譯器就是以下默認(rèn)的三個,有些用的gcc而不是g++,編譯純C++就不通過。)

(純c代碼,以下三項全部選:mingw32-gcc.exe。)



可以參考以下網(wǎng)友的問題與答案:

問題:

C Hello world: Code Blocks IDE, MinGW C compiler on windows

I can't get Code Blocks IDE to compile the hello world C program it creates when you create a new C project. I've installed MinGW and it was recognised by the IDE. But when I try to build I get the following output:

-------------- Build: Debug in TestC3 (compiler: GNU GCC Compiler)---------------mingw32-gcc.exe -Wall -g -c C:\Users\jody\codeblocks\testc3\TestC3\main.c -o obj\Debug\main.o mingw32-g++.exe -o bin\Debug\TestC3.exe obj\Debug\main.o Execution of 'mingw32-g++.exe -o bin\Debug\TestC3.exe obj\Debug\main.o' in 'C:\Users\jody\codeblocks\testc3\TestC3' failed.

Why is it trying to run?mingw32-g++.exe?as well as?mingw32-gcc.exe? (And if it shouldn't be doing this, how can I configure it not to?)


答案:

The?mingw32-gcc.exe?step is the compile step. The?mingw32-g++.exe?is the link step. This is the correct sequence and will work if your?mingw32?installation is "normal" and correct - where "normal" means you have installed the C++ as well as the C tools.

The link step is failing for you because?mingw32-g++.exe?cannot be executed, most likely because it does not exist on your?PATH. Try running?mingw32-g++.exe?at the command prompt to check. Look in the directory where?mingw32-gcc.exe?resides to see if?mingw32-g++.exe?is also there.

If your mingw32 installation has got broken somehow I suggest you uninstall and reinstall.

If you have?intentionally?installed only the C tools then that will explain what you are seeing, and it is easily fixed:

Both?mingw32-gcc.exe?and?mingw32-g++.exe?are just tool driver programs. When invoked with compilation options for?.c?files,?mingw32-gcc.exe?invokes the C compiler. When invoked with compilation options for?.cpp|cxx|...?files,?mingw32-g++.exe?invokes the C++ compiler. If either of them is invoked with linkage options then it invokes the linker.

Codeblocks by default configures?mingw32-g++.exe?to invoke the linker because it will do equally well for C projects, C++ projects and C/C++ projects, and it assumes you have the full C/C++ toolchain.

If you have not installed C++ tools and only want to build C, then you can use?mingw32-gcc.exe?to invoke both the C compiler and the linker. To configure this in the CodeBlocks IDE:

  • Navigate?Settings?->?Compiler
  • Ensure that the?Selected Compiler?is?GNU GCC
  • Tab to?Toolchain executables
  • Change?Linker for dynamic libs?from?mingw32-g++.exe?to?mingw32-gcc.exe
  • OK out of?Settings?and rebuild your project.

總結(jié)

以上是生活随笔為你收集整理的codeblocks编译出错问题的解答!(编译c++ 或者c程序)的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網(wǎng)站內(nèi)容還不錯,歡迎將生活随笔推薦給好友。