简体   繁体   English

在Mac上将GCC 4.4与NetBeans集成

[英]Integrate GCC 4.4 with NetBeans on a Mac

I've got NetBeans 6.9 installed on a Mac OS Snow Leopard. 我在Mac OS Snow Leopard上安装了NetBeans 6.9 Also, I installed gcc 4.4 through MacPorts in order to experiment with C++0x. 另外,我通过MacPorts安装了gcc 4.4以试验C ++ 0x。 I believe, by default NetBeans uses the standard Apple gcc 4.2 compiler which is invoked through a g++ symlink found in /usr/bin . 我相信,默认情况下,NetBeans使用标准的Apple gcc 4.2编译器,该编译器通过/usr/bing++符号链接调用。

My question is: how can I still use the new compiler? 我的问题是:我怎么还能使用新编译器?

I tried creating a new Tool Collection in NetBeans by specifying the default directory to /opt/local/bin which is where gcc 4.4 is present. 我尝试在NetBeans中创建一个新的工具集合 ,方法是指定/opt/local/bin的默认目录,这是gcc 4.4所在的位置。 But this caused error messages, ie No compiler sets were found... . 但是这会导致错误消息,即没有找到编译器集.... I also tried modifying the existing GNU Tool Collection by selectively specifying the C++ Compiler command as /opt/local/bin/x86_64-apple-darwin10-g++-mp-4.4 . 我还尝试通过有选择地将C ++编译器命令指定为/opt/local/bin/x86_64-apple-darwin10-g++-mp-4.4来修改现有的GNU工具集合。 However, this caused build errors which I didn't even understand. 但是,这导致了构建错误,我甚至都不理解。 Any ideas appreciated. 任何想法都赞赏。

What you describe here, adding a new tools chain with that path, just should work with gcc 4.4, see here http://forums.netbeans.org/post-70004.html 你在这里描述的,添加一个带有该路径的新工具链,就应该使用gcc 4.4,请参见http://forums.netbeans.org/post-70004.html
Are you sure nothing is missing in your GCC 4.4 ? 你确定你的GCC 4.4中没有遗漏任何东西吗?

The only missing step is to click "Reset Settings" help in Code Assistance tab after creating the tool chain, to make sure that code assistance picks the new headers. 唯一缺少的步骤是在创建工具链后单击“代码帮助”选项卡中的“重置设置”帮助,以确保代码帮助选择新的标题。

This works for me: 这对我有用:

Create a directory for your toolchain: 为您的工具链创建一个目录:

mkdir -p ~/toolchains/gcc-4.4-mp/bin

then link gcc's binaries into the bin directory 然后将gcc的二进制文件链接到bin目录

cd ~/toolchains/gcc-4.4-mp/bin
ln -fs /opt/local/bin/*-mp-4.4

and give gcc's tools their unmodified names back: 并给gcc的工具提供未经修改的名称:

for x in *-mp-4.4 ; do ln -fs $x ${x%-mp*} ; done

or 要么

for x in *-mp-4.4 ; do mv $x ${x%-mp*} ; done

Now you can add ~/toolchains/gcc-4.4-mp/bin as a new Toolchain Collection . 现在你可以添加~/toolchains/gcc-4.4-mp/bin作为新的工具链集合

Here's the "easiest" solution. 这是“最简单”的解决方案。 Edit your PATH environment variable and then open NetBeans. 编辑PATH环境变量,然后打开NetBeans。

sudo port install gcc_select
sudo gcc_select mp-gcc44

# tcsh:
setenv PATH /opt/local/bin:${PATH}

# bash:
PATH=/opt/local/bin:${PATH}; export PATH

# And then:
open /Applications/NetBeans.app

You should be good to go after that unless NetBeans (uses an absolute path to the compiler). 除非NetBeans(使用编译器的绝对路径),否则你应该好好追求它。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM