C++ 配置 Eclipse CDT 以使用 g++
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/8467937/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Configure Eclipse CDT to use g++
提问by Igor Filippov
I have cygwin installed, and I want to use Eclipse with CDT for development under Windows 7. However, I get following error:
我已经安装了 cygwin,我想在Windows 7下使用带有 CDT 的 Eclipse 进行开发。但是,我收到以下错误:
**** Build of configuration Default for project hello_cpp ****
make all
g++ -O2 -g -Wall -fmessage-length=0 -c -o hello_cpp.o hello_cpp.cpp
process_begin: CreateProcess(C:\cygwin\bin\g++.exe, g++ -O2 -g -Wall -fmessage-length=0 -c -o hello_cpp.o hello_cpp.cpp, ...) failed.
make (e=5): Access denied.
make: *** [hello_cpp.o] Error 5
**** Build Finished ****
- I'm able to use g++ as standalone compiler.
- cygwin /bin folder is added to path.
- 我可以使用 g++ 作为独立编译器。
- cygwin /bin 文件夹被添加到路径中。
After googling I found out that C:\cygwin\bin\g++.exe
is a cygwin symbolic link and Windows doesn't understand it and I need to point to the g++-3 location directly. How do I do it?
谷歌搜索后,我发现这C:\cygwin\bin\g++.exe
是一个 cygwin 符号链接,Windows 不理解它,我需要直接指向 g++-3 位置。我该怎么做?
回答by nowaq
I think you've done something wrong and need to start over again. Just installed Cygwin and Eclipse CDT (Indigo) on my Windows 7 and all works fine and auto-magicaly for me.
我认为你做错了什么,需要重新开始。刚刚在我的 Windows 7 上安装了 Cygwin 和 Eclipse CDT(Indigo),一切正常,并且对我来说是自动神奇的。
Here's what I did and I think you need to do:
这是我所做的,我认为您需要做的是:
- Get the latest Cygwin(yes, get it again! get rid of the old one just to be sure)
- During the installation make sure to select
gcc
,gcc-g++
andmake
(I additionally installed couple of other things likegcc4
,w32api
but it's optional) - Start Cygwin terminal to init all configuration files, etc. See if g++ executes and close the terminal.
- Add
C:\cygwin\bin
(or wherever else you installed it) to your EnvironmentPATH
variable - Get Eclipse CDT, extract it somewhere and start it up.
- Go to
File -> New Project -> C++ Project
and selectHello World C++ Project
. You should see theCygwin GCC
in theToolchains
list. - Create the Project, build and run it!
- 获取最新的Cygwin(是的,再次获取!摆脱旧的只是为了确保)
- 在安装过程中,请确保选择
gcc
,gcc-g++
和make
(我还安装了其他一些东西,例如gcc4
,w32api
但它是可选的) - 启动 Cygwin 终端以初始化所有配置文件等。查看 g++ 是否执行并关闭终端。
- 添加
C:\cygwin\bin
(或您安装它的任何其他地方)到您的环境PATH
变量 - 获取 Eclipse CDT,将其解压缩到某处并启动它。
- 前往
File -> New Project -> C++ Project
并选择Hello World C++ Project
。您应该会Cygwin GCC
在Toolchains
列表中看到。 - 创建项目,构建并运行它!
Done!
完毕!
Build output:
构建输出:
**** Build of configuration Debug for project TestApp ****
make all
Building file: ../src/TestApp.cpp
Invoking: Cygwin C++ Compiler
g++ -O0 -g3 -Wall -c -fmessage-length=0 -MMD -MP -MF"src/TestApp.d" -MT"src/TestApp.d" -o "src/TestApp.o" "../src/TestApp.cpp"
Finished building: ../src/TestApp.cpp
Building target: TestApp.exe
Invoking: Cygwin C++ Linker
g++ -o "TestApp.exe" ./src/TestApp.o
Finished building target: TestApp.exe
**** Build Finished ****