将gcc 4.8与Xcode 4.x集成 [英] Integrating gcc 4.8 with Xcode 4.x

查看:142
本文介绍了将gcc 4.8与Xcode 4.x集成的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图在一个Objective-C ++程序中使用OpenMP。

不幸的是,使用OpenMP时,llvm-gcc 4.2似乎有严重的错误。根据我的研究,最好的解决方案应该是使用gcc 4.8。



我已经下载了gcc 4.8的预编译版本。我的问题是:如何将新编译器与Xcode集成,以便我可以直接在Xcode的Build Settings中选择它?

或者,我可以用gcc4.8编译我的项目吗? easy ?我有不同的文件和一个.xib,我真的不想手动编译所有这些文件。



我使用的是MacOS 10.8.3和Xcode 4.5.1 (尽管我认为所有Xcode 4.x的程序都应该是一样的)。

解决方案

在Xcode 4.5中安装GCC 4.8, Xcode 4.6,Xcode 5.0:



适用于未安装GCC 4.8的用户:



安装新版本自酿啤酒

你可以找到如何在互联网上安装的方法

更新你的酿造到最新版本( $ brew update

1. $ brew install gcc48 --enable-所有语言



(可能应该通过brew安装mpc,mpfr和gmp, http://solarianprogrammer.com/2013/06/11/compiling-gcc-mac-os-x/



2。 $ brew link gcc48



3.backup g ++,gpp,c ++,cpp,c ++ in / usr / bin /



4. [可选步骤]:

别名g ++ - 4.8,gpp-4.8,c ++ - 4.8,cpp-4.8,c ++ - 4.8 $ /

local / Cellar / gcc48 / 4.8.2 / bin / g ++



/ usr / bin /

[对于没有安装gcc的开发人员,上述4个步骤]



5.制作插件

<1>下载 Xcode的GCC 4.5插件



< 2)将每个4.5改为4.8,4_5改为4_8,文件名,文件内容, 除com.apple .compilers.gcc.headers.4_2放入文件 GCC 4.5.xcspec



您可以保留内容 English.lproj 不变,并删除 Japanese.lproj



<文件 GCC 4.8.xcspec



(希望你已经改变了code> GCC 4.5.xcspec 至 GCC 4.8.xcspec


$ b的文件名$ b

更改 ExecPath =...;



ExecPath =/usr/local/bin/gcc-4.8



ExecPath =/ usr / local /地下室/ gcc48 / 4.8.2 / bin / gcc-4.8(对于通过brew安装gcc-4.8的人)



ExecPath =/ usr / bin / gcc(对于完成第4步的人)。

4)delete文件 GCC 4.8.xcspec

中的-Wshorten-64-to-32部分
$ b

  {
Name =GCC_WARN_64_TO_32_BIT_CONVERSION;
Type = Boolean;
DefaultValue = NO;
CommandLineArgs = {
YES =(
-Wshorten-64-to-32,
);
NO =();
};
AppearsAfter =GCC_WARN_PROTOTYPE_CONVERSION;
Category =警告;
CommonOption = NO;
DisplayName =隐式转换为32位类型;
Description =如果某个值从64位类型隐式转换为32位类型,则警告
[GCC_WARN_64_TO_32_BIT_CONVERSION,-Wshorten-64-to-32];
}

6.put编辑 GCC 4.8.xcplugin 转换为



/Applications/Xcode.app/Contents/Plugins/Xcode3Core.ideplugin/Contents/SharedSupport/Developer/Library/ Xcode / Plug-ins /



7.reopen Xcode。

现在,新插件已经为您准备好了。你可以在项目的Build Settings的编译器for C / C ++ / Objective-C中看到你的新GCC编译器插件。

Xcode项目


<1>在项目目标 Xcode中的设置



将C / C ++ / Objective-C编译器更改为GCC 4.8

2)在项目设置中



删除CLANG_CXX_LIBRARY行


I am trying to use OpenMP in a objective-c++ program.
Unfortunately llvm-gcc 4.2 seems to have serious bug when working with OpenMP. According to my researches, the best solution should be using gcc 4.8 instead.

I already downloaded a prebuilt version of gcc 4.8. My question is: how can I integrate the new compiler with Xcode, so that I can select it directly in Build Settings from Xcode?
Alternatively, is there an easy way I can compile my project with gcc4.8? I have different files and a .xib, I really do not want to compile all of them by hand.

I'm using MacOS 10.8.3 and Xcode 4.5.1 (though I think the procedure should be the same for all Xcode 4.x).

解决方案

install GCC 4.8 into Xcode 4.5, Xcode 4.6, Xcode 5.0:

for people who have not install GCC 4.8:

install the new version of home-brew

you can find the method how to install on the Internet

update your brew to the latest version ($brew update)

1.$brew install gcc48 --enable-all-languages

(may should install mpc, mpfr and gmp through brew, http://solarianprogrammer.com/2013/06/11/compiling-gcc-mac-os-x/)

2.$brew link gcc48

3.backup g++,gpp,c++,cpp,c++ in /usr/bin/

4.[optional step]:

alias g++-4.8,gpp-4.8,c++-4.8,cpp-4.8,c++-4.8

from /usr/local/Cellar/gcc48/4.8.2/bin/g++

to /usr/bin/

[above 4 steps for the developer who have not install gcc]

5.make plugin

1)download a plugin of GCC 4.5 for Xcode

2)change every "4.5" to "4.8", "4_5" to "4_8", the file names, the file contents,

except "com.apple.compilers.gcc.headers.4_2" in the file GCC 4.5.xcspec.

you can remain contents in English.lproj unchanged, and delete Japanese.lproj.

3)in file GCC 4.8.xcspec

(hope you have already change the file name of GCC 4.5.xcspec to GCC 4.8.xcspec)

change ExecPath = "...";

to ExecPath = "/usr/local/bin/gcc-4.8"

or ExecPath = "/usr/local/Cellar/gcc48/4.8.2/bin/gcc-4.8" (for the people who install gcc-4.8 by brew)

or ExecPath = "/usr/bin/gcc" (for the people who finished step 4.)

4)delete "-Wshorten-64-to-32" part in file GCC 4.8.xcspec

{
    Name = "GCC_WARN_64_TO_32_BIT_CONVERSION";
    Type = Boolean;
    DefaultValue = NO;
    CommandLineArgs = {
        YES = (
            "-Wshorten-64-to-32",
        );
        NO = ();
    };
    AppearsAfter = "GCC_WARN_PROTOTYPE_CONVERSION";
    Category = Warnings;
    CommonOption = NO;
    DisplayName = "Implicit Conversion to 32 Bit Type";
    Description = "Warn if a value is implicitly converted from a 64 bit type to a 32 bit type.
    [GCC_WARN_64_TO_32_BIT_CONVERSION, -Wshorten-64-to-32]";
}

6.put edited GCC 4.8.xcplugin into

/Applications/Xcode.app/Contents/Plugins/Xcode3Core.ideplugin/Contents/SharedSupport/Developer/Library/Xcode/Plug-ins/

7.reopen Xcode.

Now, the new plugin has already prepared for you. You can see your new GCC compiler plugin in the "Compiler for C/C++/Objective-C" of "Build Settings" of your project

8.change Build Settings in Xcode project

1)In the project and target settings in Xcode

change "Compiler for C/C++/Objective-C" to "GCC 4.8"

2)In the project settings

delete "CLANG_CXX_LIBRARY" row

这篇关于将gcc 4.8与Xcode 4.x集成的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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