如何将 C++ 插件安装到 Eclipse?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/12165746/
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
How to install C++ plugin to Eclipse?
提问by user1631224
I apologize beforehand for this noobish Q, but Im starting to learn C++, and have only used Java.
我事先为这个菜鸟 Q 道歉,但我开始学习 C++,并且只使用过 Java。
I have also searched here and elsewhere for a solution to this and followed all steps and still getting this error.
我也在此处和其他地方搜索过此问题的解决方案,并按照所有步骤操作,但仍然出现此错误。
I will try to be as specific as I can to help you guys.
我会尽可能具体地帮助你们。
I have eclipse helios and wanted to code C++ using it, but I keep running into the "Launch failed. Binary Not found" error.
我有 eclipse helios 并想使用它编写 C++ 代码,但我一直遇到“启动失败。找不到二进制文件”错误。
I installed the MingW C++ compiler using the "mingw-get-inst-20120426" file and selected the "C compiler, C++ compiler, MSYS Basic System, and MingW Developer Toolkit".
我使用“mingw-get-inst-20120426”文件安装了MingW C++编译器,并选择了“C编译器、C++编译器、MSYS Basic System和MingW Developer Toolkit”。
Then I went to eclipse > project > properties > C/C++ General > Paths and Symbols, then selected the GNU C++ in the Includes tab and added the "C:\MinGW\lib\gcc\mingw32\4.6.2\include\c++" path
然后我去 eclipse > project > properties > C/C++ General > Paths and Symbols,然后在 Includes 选项卡中选择了 GNU C++ 并添加了“C:\MinGW\lib\gcc\mingw32\4.6.2\include\c++ “ 小路
I also went to C/C++ build > Environment and appended the "C:\MinGW\bin;C:\MinGW\msys\1.0\bin" to the PATH.
我还转到 C/C++ build > Environment 并将“C:\MinGW\bin;C:\MinGW\msys\1.0\bin”附加到 PATH。
Then I created a Hello World C++ project, selecting the MingW GCC under Toolchains, and then build the project using the "hammer" icon.
然后我创建了一个Hello World C++项目,在Toolchains下选择MingW GCC,然后使用“锤子”图标构建项目。
However, once I ran the HelloWorld program it gets the "Launch failed. Binary Not Found" error.
但是,一旦我运行了 HelloWorld 程序,它就会出现“启动失败。找不到二进制文件”错误。
Here is another error: g++ -IC:\MinGW\lib\gcc\mingw32\4.6.2\include\c++ -O0 -g3 -Wall -c -fmessage-length=0 -osrc\HelloWorld.o ..\src\HelloWorld.cpp Internal Builder: Cannot run program "g++": The system cannot find the file specified.
这是另一个错误: g++ -IC:\MinGW\lib\gcc\mingw32\4.6.2\include\c++ -O0 -g3 -Wall -c -fmessage-length=0 -osrc\HelloWorld.o ..\src\ HelloWorld.cpp 内部生成器:无法运行程序“g++”:系统找不到指定的文件。
I also downloaded the CDT (C/C++ Development Tooling) and transferred the "features" and "plugins" folder to the eclipse folder.
我还下载了 CDT(C/C++ 开发工具)并将“功能”和“插件”文件夹转移到 eclipse 文件夹中。
Can someone please give me step-by-step on how to resolve this?
有人可以给我一步一步如何解决这个问题吗?
回答by moskito-x
Firstly, in the following examples all drive-letters should be replaced with the relevant ones on your system. Not allof these steps are really necessary, but it works (and the more the merrier).
首先,在以下示例中,所有驱动器号都应替换为系统上的相关驱动器号。并非所有这些步骤都是真正必要的,但它有效(并且越多越好)。
We start with the slightly simpler release config - we want to make it compile.
我们从稍微简单的发布配置开始——我们想让它编译。
Go to Project -- Properties
转到项目 -- 属性
Look if the include directories are correct and in place.
查看包含目录是否正确且到位。
Go to Project -- Properties -- Run/Debug Settings -- NEW -- Main Tab
转到项目--属性--运行/调试设置--新--主选项卡
Set to Release and Browse to the Release folder of the project. If the exe file is not set type in its name.
设置为 Release 并浏览到项目的 Release 文件夹。如果未设置 exe 文件,请输入其名称。
Switch to Common Tab. Check Allocate Console and Launch in Background. Don't Run yet.
切换到通用选项卡。选中分配控制台并在后台启动。不要跑。
Go to Project -- Properties -- C/C++ Build -- Discovery Options
转到项目--属性--C/C++ 构建--发现选项
Tools -- GCC C++ Compiler
工具——GCC C++ 编译器
"Browse" to the mingw bin folder and select the g++.exe or copy mingw32-g++.exe to g++.exe
“浏览”到 mingw bin 文件夹并选择 g++.exe 或将 mingw32-g++.exe 复制到 g++.exe
Note:The image points to mingw32-g++.exe please use g++.exe
注:镜像指向mingw32-g++.exe请使用g++.exe
Right click on the project and look -- Build Configurations -- Set Active -- Release is checked.
右键单击项目并查看--Build Configurations--Set Active--Release 被选中。
Right click on the project -- Run As -- Run Configurations.
右键单击项目——运行方式——运行配置。
Under C/C++ Application select, the one which refers to the release version. Then click Run
在 C/C++ Application 选择下,指的是发布版本。然后点击运行
If this works, I will show you how to set the Debug Properties. (more complicated)
如果这有效,我将向您展示如何设置调试属性。(更复杂)
回答by RS1980
Nowadays (Eclipse Juno and newer), it is much simpler. You just need to:
如今(Eclipse Juno 和更新版本),它要简单得多。你只需要:
- Install MinGW (and including C++ compiler)
- Add the paths "C:\minGW\bin" and "C:\minGW\msys\1.0\bin" (or wherever you installed MinGW to) to your Windows "Path" variable
- Install Eclipse. If Eclise already is installed, restart it. it will recognize that MinGW is now available.
- Create a New project: "C++ Project"
- For every Project type in the following dialog, you should now be able to select the "MinGW GCC" toolchain
- Happy coding
- 安装 MinGW(包括 C++ 编译器)
- 将路径“C:\minGW\bin”和“C:\minGW\msys\1.0\bin”(或您安装 MinGW 的任何位置)添加到您的 Windows“路径”变量
- 安装 Eclipse。如果已经安装了 Eclise,请重新启动它。它将认识到 MinGW 现在可用。
- 创建一个新项目:“C++ 项目”
- 对于以下对话框中的每个项目类型,您现在应该能够选择“MinGW GCC”工具链
- 快乐编码
回答by dan
回答by oenpelli
g++ is installed as part of MinGW. If you are getting an error in Eclipse that it cannot find g++ then your path is most likely incorrect. From a command prompt you should be able to run:
g++ 是作为 MinGW 的一部分安装的。如果您在 Eclipse 中遇到找不到 g++ 的错误,那么您的路径很可能是不正确的。从命令提示符您应该能够运行:
g++ --version
g++ --version
and it should display the version of g++ in the MinGW/bin directory.
它应该在 MinGW/bin 目录中显示 g++ 的版本。
Eclipse uses this path to locate the include files and the compiler. Once you get the path correct restart Eclipse and the problems listed in your question should be resolved.
Eclipse 使用此路径来定位包含文件和编译器。获得正确的路径后,重新启动 Eclipse,您的问题中列出的问题应该会得到解决。
回答by xxxtrollmodzxxx _
If you have downloaded Mingw
and restarted Eclipse then
如果您已经下载Mingw
并重新启动了 Eclipse,那么
Do this:
做这个:
Go to Project--Properties--Run/Debug Settings
->Delete any launch configurations then GOTO:
(RIGHT CLICK YOUR PROJECT)Project--Clean Project then
(RIGHT CLICK YOUR PROJECT)Project--Build Project then
run the project.