codeblocks编译出错问题的解答!(编译c++ 或者c程序)
来源:互联网 发布:用matlab求解矩阵方程 编辑:程序博客网 时间:2024/04/29 05:42
典型错误:
execution of 'mingw32-g++.exe ……faile!
codeblocks cannot exec `cc1plus': No such file or directory
出现这样的错误,都是因为编译器没安装成功,或者没有设置好!
从设置过程就可以知道有没有安装g++编译器。
设置方法:Settings——Compiler…
一般默认compiler是GNU GCC Compiler
点进Toolchain executables,下面三项中,最好点进去重新选择一遍!
如果没有安装mingw(gcc、g++)编译器,选进去的时候就找不到mingw32-g++.exe。
如此就说明没有安装mingw,可以单独下载mingw(http://download.csdn.net/detail/jingmiaa/9588535),安装,然后重新设置,在mingw安装目录下可以找到mingw32-g++.exe。
(c++代码,编译器就是以下默认的三个,有些用的gcc而不是g++,编译纯C++就不通过。)
(纯c代码,以下三项全部选:mingw32-gcc.exe。)
可以参考以下网友的问题与答案:
问题:
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 -cC:\Users\jody\codeblocks\testc3\TestC3\main.c -o obj\Debug\main.omingw32-g++.exe -o bin\Debug\TestC3.exe obj\Debug\main.o Executionof '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
tomingw32-gcc.exe
- OK out of Settings and rebuild your project.
- codeblocks编译出错问题的解答!(编译c++ 或者c程序)
- 在codeblocks中用命令行(cmd)编译运行C程序
- redhat7中Codeblocks编译c程序乱码问题 中文乱码解决方法
- linux下使用codeblocks编译mysql操作c程序错误
- codeblocks c++ 编译出错
- MAC 编译openssl1.1.0c出错问题
- neon_matrix_impl.c 编译出错
- 给codeblocks的c编译选项添加c99标准
- codeblocks按c99标准编译c文件的设置
- codeblocks按c99标准编译c文件的设置
- codeblocks按c99标准编译c文件的设置
- 编译vsftp sysdeputil.c出错的解决办法
- Mac下的C,C++编译出错
- c\c++ codeblocks编译常见错误
- codeblocks 设置C99标准编译C文件
- C程序的编译过程
- C程序的编译过程
- C程序的编译过程
- UVA 11988 - Broken Keyboard (a.k.a. Beiju Text)
- 揭秘webdriver实现原理
- 当图片有点击监听和长按监听时会产生的问题
- UsageStatsManager怎样使用问题详解和获取应用使用信息
- 如何在sublime text 3中关联python
- codeblocks编译出错问题的解答!(编译c++ 或者c程序)
- POJ 2442 优先队列
- 在java项目中使用Log4j -1- 概述
- ios开发中获取常用的应用与设备信息
- HDUOJ 1870 - 愚人节的礼物
- CATransaction 动画暂停
- 将百度定位封装为library
- Logstash官方文档中文版-第一个例子
- Python import 功能(进阶篇)