Search code examples
c++c++11buildrootbuild-system

Is possible to pass C++11 param to Buildroot config?


I want to build boost and other packages in buildroot with -std=c++11? Is it possible to pass it globally, instead by patching program .mk files ?


Solution

  • There is no easy way to pass it globally, and for a good reason: some packages may not build with C++11, e.g. because they use new reserved words.

    If you really want to risk it, however, you have three options:

    • Add -std=c++11 to BR2_TARGET_OPTIMIZATION (in the Toolchain menu). This will be included in the toolchain wrapper and therefore be used for each compile. Note that for C programs, this will give you "command line option ‘-std=c++11’ is valid for C++/ObjC++ but not for C" warnings. So packages that to -Werror will break.

    • Modify package/Makefile.in and add -std=c++11 to TARGET_CXXFLAGS. In this case, it's only passed to C++ compiles. However, TARGET_CXXFLAGS is just passed to the package build system and not all build systems honor it.

    • Modify toolchain/toolchain-wrapper.c to add this option when g++ is called. This doesn't have the disadvantages of the other two, but is more work to implement.