2013年8月16日 星期五

[OSX] 使用 MacPorts 安裝 Boost 1.54.0 和 wxWidgets 2.9.5 (c++11, std=c++11, stdlib=libc++) @ Mac 10.8

最近用有案子 Boost 1.54.0 和 wxWidgets 2.9.5 來開發 OSX app,而採用 MacPorts 預設安裝 boost 跟 wxwidgets30 都只是預編好的,就算用 port -s 參數編出來的仍不支援 C++11。

然而編譯 boost 1.54.0 支援 c++11 也可以考慮用 brew 來安裝,只要加參數即可:

$ ruby -e "$(curl -fsSL https://raw.github.com/mxcl/homebrew/go)"
$ brew info boost
boost: stable 1.54.0 (bottled), HEAD
http://www.boost.org
Not installed
From: https://github.com/mxcl/homebrew/commits/master/Library/Formula/boost.rb
==> Options
--universal
        Build a universal binary
--with-c++11
        Compile using Clang, std=c++11 and stdlib=libc++
--with-icu
        Build regexp engine with icu support
--with-mpi
        Build with mpi support
--without-python
        Build without python support
--without-single
        Disable building single-threading variant
--without-static
        Disable building static library variant
$ brew install boost --with-c++11


但 brew 裡的 wxwidgets 只有到 2.9.4 版:

$ brew info wxwidgets
wxmac: stable 2.9.4.0
http://www.wxwidgets.org
Not installed
From: https://github.com/mxcl/homebrew/commits/master/Library/Formula/wxmac.rb
==> Options
--without-python
        Build without python support


摸索了一下 MacPorts 後,可以透過參數編譯使之支援 C++11:

$ port info boost wxwidgets30
boost @1.54.0 (devel)
Variants:             debug, [+]no_single, [+]no_static, openmpi, python25, python26, [+]python27, python31, python32, python33,
                      regex_match_extra, universal

Description:          Boost provides free portable peer-reviewed C++ libraries. The emphasis is on portable libraries which work
                      well with the C++ Standard Library.
Homepage:             http://www.boost.org

Library Dependencies: zlib, expat, bzip2, libiconv, icu, python27
Platforms:            darwin
License:              Boost-1
Maintainers:          nomaintainer@macports.org
--
wxWidgets30 @2.9.5_2 (graphics, devel)
Variants:             aui, debug, monolithic, [+]sdl, stdlib, universal

Description:          wxWidgets is a mature open-source cross-platform C++ GUI framework for Mac OS, Unix, Linux, Windows. It can
                      make use of a variety of native widget sets as well as its own widget set: Mac OS, GTK+, Motif, WIN32.
                      wxWidgets will even run on embedded systems using Linux and X11.
Homepage:             http://www.wxwidgets.org/

Library Dependencies: jpeg, tiff, libpng, zlib, libiconv, expat, libsdl, libsdl_mixer
Conflicts with:       wxgtk, wxWidgets
Platforms:            darwin
License:              wxwidgets-3.1
Maintainers:          jwa@macports.org, mojca@macports.org

$ sudo port install wxwidgets30
$ sudo port uninstall wxwidgets30
$ sudo port install -s wxWidgets30 configure.cc=clang configure.cxx="clang++ -std=c++11 -stdlib=libc++" configure.cxxflags="-std=c++11 -stdlib=libc++ -O2" configure.objcxxflags="-std=c++11 -stdlib=libc++ -O2"

$ sudo port install boost
$ sudo port uninstall boost
$ sudo port install -s boost configure.cc=clang configure.cxx="clang++ -std=c++11 -stdlib=libc++" configure.cxxflags="-std=c++11 -stdlib=libc++ -O2" configure.objcxxflags="-std=c++11 -stdlib=libc++ -O2"

沒有留言:

張貼留言