Integrating gcc 4.8 with Xcode 4.x

前端 未结 2 758
无人共我
无人共我 2020-12-15 14:49

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 bes

相关标签:
2条回答
  • 2020-12-15 15:09

    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

    0 讨论(0)
  • 2020-12-15 15:12

    In Xcode, in your project, select the project (the root of the files, with the blue icon). In the view that opens, select the project again, then select the tab "Build Settings".

    Search here the entry "Compiler for C/C++/Objective-C (there is a search box above the table view). Edit the value and set a custom path (by selecting "Other…") to the gcc you downloaded.

    0 讨论(0)
提交回复
热议问题