Box2D编译麻烦.nullptr

Box2D compiling trouble. nullptr

本文关键字:nullptr 麻烦 编译 Box2D      更新时间:2023-10-16

伙计们。我正在从源代码中编译Box2D,并带来一些麻烦。我在Box2D目录中运行了睫毛版本,然后切换到/build/gmake并跑步。让我回来:

../../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)
               ^

Enyone可以帮助我吗?我使用Ubuntu Linux 14.04。

我通过add -std = gnu 0x解决我的问题,以由premake生成

生成

premake文件(premake5.lua)在此片段中提到C 11:

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

它似乎不起作用。这可能与此问题有关,该问题的解决方案是使用cppdialect,该问题仅在Premake 5 Alpha 12中可用(在撰写本文时,最后一个版本是Alpha 11,这意味着您需要直接在Github上直接下载最新版本)。

作为快速解决方案,您可以按照OP的答案:通过添加-std=c++11(resp。gnu++11c++14等)将Box2D(也是Helloworld和TestBend)修改的MAKE FILES:将其修改为ALL_CXXFLAGS

如果您喜欢修改预制本身:

  1. premake5.lua 中,评论上面提到的过滤器/buildoptions aippet
  2. 在Projects Box2D(也需要Helloworld和TestBed(如果需要))中,添加flags "C++11"(您还可以添加buildoptions { "-std=c++11" },唯一的区别是它也会将选项添加到All_cflags)

示例:

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

我打算使用此更改将PR发送到Box2D的存储库。

编辑:完成,这是Pr。