hugoam / two

c++ toolkit for rapid development of live graphical apps and games
zlib License
1.68k stars 92 forks source link

build failing on BgfxSystem.cpp #18

Closed npisanti closed 4 years ago

npisanti commented 5 years ago

I tried to compile two as described in README.md but i got those compiler errors, i'm on Debian 9:

BgfxSystem.cpp
In file included from ../../../src/ctx/Context.h:10:0,
                 from ../../../src/ctx-glfw/GlfwContext.h:11,
                 from ../../../src/bgfx/BgfxSystem.h:13,
                 from ../../../src/bgfx/BgfxSystem.cpp:17:
../../../src/math/Vec.h:208:32: error: ‘two::x3’ declared as an ‘inline’ variable
  export_ constexpr inline vec3 x3 = { 1.f, 0.f, 0.f };
                                ^~
../../../src/math/Vec.h:209:32: error: ‘two::y3’ declared as an ‘inline’ variable
  export_ constexpr inline vec3 y3 = { 0.f, 1.f, 0.f };
                                ^~
../../../src/math/Vec.h:210:32: error: ‘two::z3’ declared as an ‘inline’ variable
  export_ constexpr inline vec3 z3 = { 0.f, 0.f, 1.f };
                                ^~
../../../src/math/Vec.h:212:32: error: ‘two::ZeroQuat’ declared as an ‘inline’ variable
  export_ constexpr inline quat ZeroQuat = { 0.f, 0.f, 0.f, 1.f };
                                ^~~~~~~~
../../../src/math/Vec.h:214:32: error: ‘two::Rect4’ declared as an ‘inline’ variable
  export_ constexpr inline vec4 Rect4 = { 0.f, 0.f, 1.f, 1.f };
                                ^~~~~
hugoam commented 5 years ago

This is due to two now using C++17 features, so it wouldn't compile if your compiler isn't fully C++17 compliant I think (which is probably what's happening here).

npisanti commented 5 years ago

yes you are right, gcc in debian is version 6 and version 7 is needed for c++17. I've also got clang and clang-6.0 repo installed, the latter should be able to compile c++17, how can i use it to build two?

hugoam commented 5 years ago

You need to call genie with different parameters to use clang: bin/linux/genie --gcc=linux-clang gmake this will generate the makefiles in the folder build/projects/linux-clang IIRC

npisanti commented 5 years ago

that won't works as it will use the default clang version, that is 3.8, and bin/linyx/genie --gcc=linux-clang-6.0 gives an error as output, i should try to find a way to change the default clang version, maybe using debian alternatives

hugoam commented 5 years ago

Hmmm, right, you might have to edit the script to make that work (they aren't very flexible with that for now) by adding an entry linux-clang-6 here and here, with the same logic as for regular clang but with the more specific compiler name/path

hugoam commented 5 years ago

In the future we could add an option tool-suffix or compiler-suffix to make this more flexible so you don't have to mess with the toolchain file.

npisanti commented 5 years ago

i was able to compile the file for this issue with your adviced changes, but now i get an error on a different file

../../../src/stl/type_traits.h:15:50: error: no template named
      'is_trivially_destructible_v' in namespace 'std'; did you mean
      'is_trivially_destructible'?
  ...bool is_trivially_destructible = std::is_trivially_destructible_v<T>;

should i open another issue and close this? i can fix that by changing std::is_trivially_destructible_v<T> to std::is_trivially_destructible<T>() but then i got other compile errors

hugoam commented 4 years ago

This is most likely a problem of C++ STL version associated to your compiler. Those helpers have been added in C++17. Your compiler is probably using an anterior version of the STL here because of the magic ways through which gcc (and clang) decides what STL location it's using to compile