How to install Boost with specified compiler (say GCC)

前端 未结 2 699
渐次进展
渐次进展 2020-12-30 17:46

I would like to install boost with specified compilers, such as the gcc-4.9.1 that I have installed in . The curren

2条回答
  •  悲哀的现实
    2020-12-30 18:30

    I am using Mac Yosemite and this worked for me.

    Open "tools/build/example/user-config.jam" and change

    # Configure gcc (default version).
    # using gcc ;
    
    # Configure specific gcc version, giving alternative name to use.
    

    using darwin : 5 : g++-5 ;

    Then open "tools/build/src/tools/darwin.jam" then delete below line (this step may not be required. just try both way);

    "$(CONFIG_COMMAND)" -dynamiclib -Wl,-single_module -install_name "$(<:B)$(<:S)" -L"$(LINKPATH)" -o "$(<)" "$(>)" "$(LIBRARIES)" -l$(FINDLIBS-SA) -l$(FINDLIBS-ST) $(FRAMEWORK_PATH) -framework$(_)$(FRAMEWORK:D=:S=) $(OPTIONS) $(USER_OPTIONS)
    

    As last step, compile and install

    $ ./bootstrap.sh --with-libraries=all --with-toolset=darwin --prefix=/usr/local/boost_for_gcc
    $ ./b2
    $ ./b2 install
    

    Now you can compile your code like below

    $ g++ -o main main.cpp -L/usr/local/boost_for_gcc/lib -I/usr/local/boost_for_gcc/include -lboost_regex
    

    Reference: http://qiita.com/misho/items/0c0b3ca25bb8f62aa681

提交回复
热议问题