JoeyDeVries/LearnOpenGL

Chapter 8 has lots of ERROR!

AstroWYH opened this issue · 4 comments

Dear Author:
when I use cmake to compile the whole project, I find there're lot's of ERROR in chap 8.
If I delete chap 8 in CMakeLists at root path, there's no error.
Hope can notice it!
Thank U

+1
When compiling on Ubuntu Linux 20.04.1, after installing the dependencies as described in the readme, I've got the following output:

/LearnOpenGL/includes/learnopengl/entity.h: In constructor 'Entity::Entity(Model&)':
/LearnOpenGL/includes/learnopengl/entity.h:402:25: error: 'make_unique' is not a member of 'std'
  402 |   boundingVolume = std::make_unique<AABB>(generateAABB(model));
      |                         ^~~~~~~~~~~
/LearnOpenGL/includes/learnopengl/entity.h:402:25: note: 'std::make_unique' is only available from C++14 onwards
/LearnOpenGL/includes/learnopengl/entity.h:402:41: error: expected primary-expression before '>' token
  402 |   boundingVolume = std::make_unique<AABB>(generateAABB(model));
      |                                         ^
In file included from /LearnOpenGL/src/8.guest/2021/1.scene/2.frustum_culling/frustum_culling.cpp:12:
/LearnOpenGL/includes/learnopengl/entity.h: In member function 'void Entity::addChild(TArgs& ...)':
/LearnOpenGL/includes/learnopengl/entity.h:435:30: error: 'make_unique' is not a member of 'std'
  435 |   children.emplace_back(std::make_unique<Entity>(args...));
      |                              ^~~~~~~~~~~
/LearnOpenGL/includes/learnopengl/entity.h:435:30: note: 'std::make_unique' is only available from C++14 onwards
/LearnOpenGL/includes/learnopengl/entity.h:435:48: error: expected primary-expression before '>' token
  435 |   children.emplace_back(std::make_unique<Entity>(args...));
      |                                                ^
/LearnOpenGL/includes/learnopengl/entity.h:435:57: error: expected binary operator before ')' token
  435 |   children.emplace_back(std::make_unique<Entity>(args...));

And after removing the "set(CMAKE_CXX_STANDARD 11)" in CMakeLists.txt I get:

/LearnOpenGL/src/8.guest/2021/1.scene/1.scene_graph/scene_graph.cpp: In function 'int main()':
/LearnOpenGL/src/8.guest/2021/1.scene/1.scene_graph/scene_graph.cpp:101:38: error: cannot bind non-const lvalue reference of type 'Model&' to an rvalue of type 'Model'
  101 |  Entity ourEntity(FileSystem::getPath("resources/objects/planet/planet.obj"));
      |                   ~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from /LearnOpenGL/src/8.guest/2021/1.scene/1.scene_graph/scene_graph.cpp:11:
/LearnOpenGL/includes/learnopengl/model.h:36:5: note:   after user-defined conversion: 'Model::Model(const string&, bool)'
   36 |     Model(string const &path, bool gamma = false) : gammaCorrection(gamma)
      |     ^~~~~
In file included from /LearnOpenGL/src/8.guest/2021/1.scene/1.scene_graph/scene_graph.cpp:12:
/LearnOpenGL/includes/learnopengl/entity.h:400:16: note:   initializing argument 1 of 'Entity::Entity(Model&)'
  400 |  Entity(Model& model) : pModel{ &model }
      |         ~~~~~~~^~~~~
/LearnOpenGL/src/8.guest/2021/1.scene/1.scene_graph/scene_graph.cpp:111:44: error: cannot bind non-const lvalue reference of type 'std::__cxx11::basic_string<char>&' to an rvalue of type 'std::string' {aka 'std::__cxx11::basic_string<char>'}
  111 |    lastEntity->addChild(FileSystem::getPath("resources/objects/planet/planet.obj"));
      |                         ~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from /LearnOpenGL/src/8.guest/2021/1.scene/1.scene_graph/scene_graph.cpp:12:
/LearnOpenGL/includes/learnopengl/entity.h:433:22: note:   initializing argument 1 of 'void Entity::addChild(TArgs& ...) [with TArgs = {std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >}]'
  433 |  void addChild(TArgs&... args)
      |                ~~~~~~^~~~~~~~
/LearnOpenGL/src/8.guest/2021/1.scene/1.scene_graph/scene_graph.cpp:157:16: error: 'class Entity' has no member named 'Draw'
  157 |    lastEntity->Draw(ourShader);

Hey guys!

These errors are not affecting the original articles. You should be able to build them just fine. If the errors bother you, you can comment out the troublesome article(s) here. Unfortunately some of these errors only the authors can fix.

@arseniy-sonar the unique-ptr issues were caused by C++11 compilation as you correctly identified. That should be bumped to 14 at least. I will submit a PR of this, thanks for noticing!

lpapp commented

The PR for this broke the build for me: #283