Eclipse不会在Mac上使用gcc 4.7 [英] Eclipse will not use gcc 4.7 on Mac

查看:210
本文介绍了Eclipse不会在Mac上使用gcc 4.7的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用macports安装了gcc47。我用select来让gcc47成为我的活动编译器。当我在终端输入gcc --version时,我得到:
gcc(MacPorts gcc47 4.7.2_2)4.7.2
版权所有(C)2012自由软件基金会,Inc.
这是免费的软件;请参阅复制条件的来源。没有任何b $ b保修;甚至不适用于适销性或针对特定用途的适用性。

当我尝试在Eclipse中编译c ++代码时,我得到:
调用:GCC C ++编译器
g ++ -D__GXX_EXPERIMENTAL_CXX0X__ -I / Users / XXXX / QtSDK / Madde / sysroots / harmattan_sysroot_10.2011.34-1_slim / usr -O0 -g3 -Wall -c -fmessage-length = 0 -std = c ++ 0x -MMD -MP - MFXXXX_Process.d-MTXXXX_Process.d-oXXXX_Process.o../XXXX_Process.cpp
cc1plus:错误:无法识别的命令行选项-std = c ++ 0x
make: * [XXXX_Process.o]错误1



我不知道我没有做什么来完成这项工作。我需要一个更新的编译器来编写我在学校写的程序。感谢您的帮助。

解决方案

问题是在eclipse的路径上发现的顺序不同于那个顺序你的终端。我已经尝试了上面提示的符号链接,但仍然没有解决我的问题,但是这样做!



经过大量搜索并尝试其他事情后,我能够手动在项目 - >中设置我的编译器和链接器的路径。属性 - > C / C ++构建 - >从终端设置



,做一个g ++来找出你的g ++版本的安装位置。我的是 / opt / local / bin / g ++



点击GCC C ++编译器,并填写命令与它的完整路径(例如 / opt / local / bin / g ++ )。点击杂项以确保添加 -std = c ++ 11 标志。



做同样的事情对于GCC C编译器(将命令设置为完整路径 / opt / local / bin / g ++ ),GCC C ++链接器( / opt / local / bin / g ++ )和GCC汇编程序( / opt / local / bin / as )。

这最后为我工作,我希望它能解决您的问题!


I installed gcc47 using macports. I used select to make gcc47 my active compiler. When I type gcc --version in terminal I get this: gcc (MacPorts gcc47 4.7.2_2) 4.7.2 Copyright (C) 2012 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

When I try to compile c++ code in Eclipse I get: Invoking: GCC C++ Compiler g++ -D__GXX_EXPERIMENTAL_CXX0X__ -I/Users/XXXX/QtSDK/Madde/sysroots/harmattan_sysroot_10.2011.34-1_slim/usr -O0 -g3 -Wall -c -fmessage-length=0 -std=c++0x -MMD -MP -MF"XXXX_Process.d" -MT"XXXX_Process.d" -o "XXXX_Process.o" "../XXXX_Process.cpp" cc1plus: error: unrecognized command line option "-std=c++0x" make: * [XXXX_Process.o] Error 1

I am not sure what I am not doing to make this work. I need a more up to date compiler for programs I am writing in my for school. Thanks in advance for your help.

解决方案

The problem is the order of discovery on the path for eclipse is different then the order in your terminal. I had tried symlinking as suggest above and that still didn't fix my problem, but this did!

After much searching around and trying other things, I was able to manually set the path to my compilers and linkers in Project -> Properties -> C/C++ Build -> Settings.

from the terminal, do a which g++ to find out where your proper version of g++ is installed. Mine is in /opt/local/bin/g++

Click on GCC C++ Compiler, and fill in the command with it's full path (eg. /opt/local/bin/g++). Click on Miscellaneous to make sure you add the -std=c++11 flag.

Do the same thing for GCC C Compiler (set the command to the full path /opt/local/bin/g++), The GCC C++ Linker (/opt/local/bin/g++), and the GCC Assembler (/opt/local/bin/as).

This FINALLY worked for me, I hope it solves your problem!

这篇关于Eclipse不会在Mac上使用gcc 4.7的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆