0

guys. I am compiling Box2D from the source code, and give some trouble. I ran lash version of premake in Box2D directory, then I switched to /Build/gmake and ran make. Make return me this:

../../Box2D/Dynamics/b2Body.cpp: In member function ‘void b2Body::DestroyFixture(b2Fixture*)’:
../../Box2D/Dynamics/b2Body.cpp:216:17: error: ‘nullptr’ was not declared in this scope
if (fixture == nullptr)
               ^

Can enyone help me? I use Ubuntu Linux 14.04.

Nicol Bolas
  • 449,505
  • 63
  • 781
  • 982

2 Answers2

0

I solve my problem by add -std=gnu++0x to makefile, generated by premake

Nicol Bolas
  • 449,505
  • 63
  • 781
  • 982
0

The premake file (premake5.lua) mentions C++11 with this snippet:

filter { "language:C++", "toolset:gcc" }
    buildoptions { "-std=c++11" }

does it doesn't seem to work. This is probably related to this issue, whose solution is to use cppdialect which is only available from premake 5 alpha 12 (at the time of writing, last release is alpha 11, which means you need to download the latest version directly on GitHub).

As a quick fix, you can follow the OP's own answer: modify the Make files of Box2D (also HelloWorld and Testbed if needed) by adding -std=c++11 (resp. gnu++11, c++14, etc.) to ALL_CXXFLAGS.

If you prefer modifying the premake itself:

  1. In premake5.lua, Comment out the filter / buildoptions snippet mentioned above
  2. In projects Box2D (also HelloWorld and Testbed if needed), add flags "C++11" (you can also add buildoptions { "-std=c++11" }, the only difference is that it will also add the option to ALL_CFLAGS)

Example:

project "Box2D"
    kind "StaticLib"
    language "C++"
    flags "C++11"  -- added
    files { "Box2D/**.h", "Box2D/**.cpp" }
    includedirs { "." }

I intend to send a PR to Box2D's repository with this change.

EDIT: Done, here is the PR.

hsandt
  • 709
  • 7
  • 12