boostg++b2g++4.8

Setup toolset configuration for building boost libraries on Mac with g++ 4.8


I'm trying to build boost libraries on Mac with g++4.8 installed from port.

I made ~/user-config.jam and added one line using gcc : : g++-mp-4.8 ; go use the g++ 4.8 compiler. I have bjam and b2 installed with brew install bjam.

The issue is that when I build boost with b2 command, I have this link error:

ld: unknown option: -R
collect2: error: ld returned 1 exit status

It's because g++4.8 can't recognize the -R option as Apple's g++ 4.2 does.

How can I set the build options for g++4.8? This is the command that b2 uses. I have this site for configuration information, but I couldn't find useful information for setting up toolset configuration.

"g++-mp-4.8"  -Wl,-R -Wl,"/System/Library/Frameworks/Python.framework/Versions/2.7/lib" 
-Wl,-R -Wl,"/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/config"  -o 
"stage/lib/libboost_system.dylib" -Wl,-h -Wl,libboost_system.dylib -shared -Wl,--start-group 
"bin.v2/libs/system/build/gcc-4.8.0/release/threading-multi/error_code.o"  -Wl,-Bstatic  -Wl,
-Bdynamic  -Wl,--end-group  

Solution

  • This is an error for generating dylib files with g++. I don't think it's necessary or even possible to generate dylib file with g++, but I just found a way to remove the error. I didn't check if the generated dylib works well. I could get the static library files without a problem, so it will be OK to use the libraries with g++4.8.

    The issue is that there are many options that g++ cannot recognize: -h -B -R when building dylib file. If you just want the static library, you can get them.

    I had to modify the gcc.jam file not to give the options.

    From .../tools/build/v2/tools/gcc.jam

    Uncomment the code that generates wrong options.

    Line 855-858 to remove the -B option

    # toolset.flags $(toolset).link FINDLIBS-ST-PFX
    #     $(condition)/<runtime-link>shared : -Wl,-Bstatic : unchecked ;
    # toolset.flags $(toolset).link FINDLIBS-SA-PFX
    #     $(condition)/<runtime-link>shared : -Wl,-Bdynamic : unchecked ;
    

    Line 815-820 to remove the -R option

    #toolset.flags $(toolset).link OPTIONS     $(condition)/<strip>on : -Wl,--strip-all   : unchecked ;
    #toolset.flags $(toolset).link RPATH       $(condition)           : <dll-path>        : unchecked ;
    #toolset.flags $(toolset).link RPATH_LINK  $(condition)           : <xdll-path>       : unchecked ;
    #toolset.flags $(toolset).link START-GROUP $(condition)           : -Wl,--start-group : unchecked ;
    #toolset.flags $(toolset).link END-GROUP   $(condition)           : -Wl,--end-group   : unchecked ;
    

    Line 479 to remove -h option

    #SONAME_OPTION = -h ;