DethRaid / wad2gltf

WAD to glTF converter
Mozilla Public License 2.0
16 stars 6 forks source link

Build errors on Mac M1 and how to #6

Open vicentematus opened 7 months ago

vicentematus commented 7 months ago

What im trying to do is to convert from the DOOM game WAD files to GLTF files so i can use them in Three.js via the GLTFLoader.

Currently i'm trying to run the project but i'm not clear on how to. Here is the technical description: Running this on a M1 Mac Pro. After the fix on #4 i run the following commands to run the project:

cmake .

Which runs succesfully.

And after that on the same directory:

make

Which throws the following output

See more

```bash [ 8%] Built target fastgltf [ 9%] Building CXX object wad2gltf/CMakeFiles/wad2gltf.dir/gltf_export.cpp.o In file included from /Users/vicentematus/Documents/programacion/varios/svelte-fun/wad2gltf/wad2gltf/gltf_export.cpp:1: In file included from /Users/vicentematus/Documents/programacion/varios/svelte-fun/wad2gltf/wad2gltf/gltf_export.hpp:8: In file included from /Users/vicentematus/Documents/programacion/varios/svelte-fun/wad2gltf/wad2gltf/mesh.hpp:10: In file included from /Users/vicentematus/Documents/programacion/varios/svelte-fun/wad2gltf/wad2gltf/texture_reader.hpp:5: In file included from /Users/vicentematus/Documents/programacion/varios/svelte-fun/wad2gltf/wad2gltf/wad.hpp:12: /Users/vicentematus/Documents/programacion/varios/svelte-fun/wad2gltf/wad2gltf/wad_name.hpp:49:13: warning: expression result unused [-Wunused-value] for(i; i < len; i++) { ^ /Users/vicentematus/Documents/programacion/varios/svelte-fun/wad2gltf/wad2gltf/wad_name.hpp:53:13: warning: expression result unused [-Wunused-value] for(i; i < 8; i++) { ^ /Users/vicentematus/Documents/programacion/varios/svelte-fun/wad2gltf/wad2gltf/wad_name.hpp:104:13: error: explicit specialization of non-template struct 'formatter' struct std::formatter : std::formatter { ^ ~~~~~~~~~~~ /Users/vicentematus/Documents/programacion/varios/svelte-fun/wad2gltf/wad2gltf/wad_name.hpp:104:13: error: no struct named 'formatter' in namespace 'std' struct std::formatter : std::formatter { ~~~~~^ /Users/vicentematus/Documents/programacion/varios/svelte-fun/wad2gltf/wad2gltf/wad_name.hpp:104:41: error: unknown template name 'formatter' struct std::formatter : std::formatter { ^ In file included from /Users/vicentematus/Documents/programacion/varios/svelte-fun/wad2gltf/wad2gltf/gltf_export.cpp:1: In file included from /Users/vicentematus/Documents/programacion/varios/svelte-fun/wad2gltf/wad2gltf/gltf_export.hpp:8: In file included from /Users/vicentematus/Documents/programacion/varios/svelte-fun/wad2gltf/wad2gltf/mesh.hpp:10: In file included from /Users/vicentematus/Documents/programacion/varios/svelte-fun/wad2gltf/wad2gltf/texture_reader.hpp:5: /Users/vicentematus/Documents/programacion/varios/svelte-fun/wad2gltf/wad2gltf/wad.hpp:88:47: error: no member named 'format' in namespace 'std' throw std::runtime_error{std::format("Could not find requested lump {}", lump_name)}; ~~~~~^ /Users/vicentematus/Documents/programacion/varios/svelte-fun/wad2gltf/wad2gltf/gltf_export.cpp:245:42: error: no member named 'format' in namespace 'std' const auto image_filename = std::format("textures/{}.png", gltf_texture.name); ~~~~~^ /Users/vicentematus/Documents/programacion/varios/svelte-fun/wad2gltf/wad2gltf/gltf_export.cpp:287:26: error: no member named 'format' in namespace 'std' node.name = std::format("{} Sector {}", name, sector_index); ~~~~~^ /Users/vicentematus/Documents/programacion/varios/svelte-fun/wad2gltf/wad2gltf/gltf_export.cpp:306:26: error: no member named 'format' in namespace 'std' mesh.name = std::format("{} Sector {}", name, sector_index); ~~~~~^ /Users/vicentematus/Documents/programacion/varios/svelte-fun/wad2gltf/wad2gltf/gltf_export.cpp:331:30: error: no member named 'format' in namespace 'std' node.name = std::format("Thing {}", thing_counter); ~~~~~^ 2 warnings and 8 errors generated. make[2]: *** [wad2gltf/CMakeFiles/wad2gltf.dir/gltf_export.cpp.o] Error 1 make[1]: *** [wad2gltf/CMakeFiles/wad2gltf.dir/all] Error 2 make: *** [all] Error 2 ```

Are this the correct build steps to use the wad2gltf library? If you can post an step by step it would be amazing. Thank you very much.

DethRaid commented 7 months ago

You're doing the right build steps. Use CMake to generate build files, then invoke your build tool to build them

std::format is a part of C++20 https://en.cppreference.com/w/cpp/utility/format/format. You'll need a compiler and standard library with full C++20 support. Try upgrading your compiler if it's not at the latest version. If it is at the latest version, ask Apple to get with the times and support C++20

DethRaid commented 7 months ago

According to https://en.cppreference.com/w/cpp/compiler_support/20 std::format should be in Apple Clang 15.0.0 or later

vicentematus commented 7 months ago

Thanks for the help. I will keep you updated because im searching on how to specify the c++ version trying to specify with the flag:

make -std=c++20

but its kinda weird how its work with Mac OS. There's something related to XCode and the LLVM version from what i read. Going to comment this when i figure this out 👍🏻

DethRaid commented 7 months ago

CMake should be adding the C++ version to the makefiles it generates. You'd get all kinds of issues if it wasn't

vicentematus commented 7 months ago

🤦🏻 lol my bad. Not very familiarized with C/C++ besides some intro classes on CS. Where should i modify the version of C++? It's the file CMakeList.txt? Appreciate your help.

DethRaid commented 7 months ago

I'm already setting the C++ version - https://github.com/DethRaid/wad2gltf/blob/main/CMakeLists.txt#L6

Someone else had a problem with a compiler not respecting my choice of C++ version, so maybe there's a bit of CMake that I'm missing

vicentematus commented 7 months ago

Ohh, I see. Maybe a better workaround is just to build this on another OS. What operating system are you using to build this repository?

DethRaid commented 7 months ago

I'm on Windows 11, using Visual Studio 17.8.4

vicentematus commented 7 months ago

Going to try this on Windows. I will keep you updated.

vicentematus commented 7 months ago

Currently I don't have access to a Windows OS nor Linux. But a friend with Arch Linux helped me debug, and tried using Github Actions to run it. You can check the fork here with GH actions and the deploy.yml file

name: wad2gltf-github-actions
run-name: Wad2gltf runner
on: [push]

jobs:
  build:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - run: sudo apt update
      - name: check g version
        run: g++ --version
      - name: check gcc version
        run: gcc --version
      - name: build application with cmake
        run: cmake .
      - name: make build
        run: make

CMake runs perfectly but make fails. You can see the output here. It throws the following:

/home/runner/work/wad2gltf-gh-actions/wad2gltf-gh-actions/wad2gltf/wad.hpp:6:10: fatal error: format: No such file or directory
    6 | #include <format>
      |          ^~~~~~~~

The Github actions ubuntu-latest image runs g++ 11.4.0 and gcc 11.4.0. You can see more of the specs here. Are these the correct versions to build this based on ubuntu-latest?

DethRaid commented 7 months ago

According to https://en.cppreference.com/w/cpp/compiler_support, you need GCC libstdc++ 13 or higher for <format>. Looks like the Ubuntu image on GitHub only has GCC 11

You're going to need to get a newer compiler

DethRaid commented 7 months ago

Looks like XCode 15.3 has support for std::format, you might be able to upgrade and compile this project

vicentematus commented 7 months ago

That's viable. Going to try it with XCode.

I can't seem to change the version of GCC in GH Actions. Maybe im going to open a thread on the official repo of github/actions.

Thank you for your patience