mgerdes / Open-Golf

A cross-platform minigolf game written in C.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Build error on macOS

rblath opened this issue · comments

commented

Following your build instructions, I get an error with sokol. I think it wants to have a gfx option defined somewhere:

$ build/build-osx.sh
-- The C compiler identification is AppleClang 13.0.0.13000029
-- The CXX compiler identification is AppleClang 13.0.0.13000029
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/cc - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/c++ - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Configuring done
-- Generating done
-- Build files have been written to: /Users/rblath/Projects/GitHub/Open-Golf/out/osx
[ 1%] Building CXX object src/3rd_party/cimgui/imgui/CMakeFiles/imgui.dir/imgui.cpp.o
[ 3%] Building CXX object src/3rd_party/cimgui/imgui/CMakeFiles/imgui.dir/imgui_demo.cpp.o
[ 4%] Building CXX object src/3rd_party/cimgui/imgui/CMakeFiles/imgui.dir/imgui_draw.cpp.o
[ 6%] Building CXX object src/3rd_party/cimgui/imgui/CMakeFiles/imgui.dir/imgui_tables.cpp.o
[ 7%] Building CXX object src/3rd_party/cimgui/imgui/CMakeFiles/imgui.dir/imgui_widgets.cpp.o
[ 9%] Linking CXX static library libimgui.a
[ 9%] Built target imgui
[ 10%] Building CXX object src/3rd_party/cimgui/CMakeFiles/cimgui.dir/cimgui.cpp.o
[ 12%] Linking CXX static library libcimgui.a
[ 12%] Built target cimgui
[ 13%] Building C object src/3rd_party/fast_obj/CMakeFiles/fast_obj.dir/fast_obj.c.o
[ 15%] Linking C static library libfast_obj.a
[ 15%] Built target fast_obj
[ 16%] Building C object src/3rd_party/glad/CMakeFiles/glad.dir/glad.c.o
[ 18%] Linking C static library libglad.a
[ 18%] Built target glad
[ 19%] Building C object src/3rd_party/glfw/CMakeFiles/glfw.dir/src/context.c.o
[ 21%] Building C object src/3rd_party/glfw/CMakeFiles/glfw.dir/src/init.c.o
[ 22%] Building C object src/3rd_party/glfw/CMakeFiles/glfw.dir/src/input.c.o
[ 24%] Building C object src/3rd_party/glfw/CMakeFiles/glfw.dir/src/monitor.c.o
[ 25%] Building C object src/3rd_party/glfw/CMakeFiles/glfw.dir/src/platform.c.o
[ 27%] Building C object src/3rd_party/glfw/CMakeFiles/glfw.dir/src/vulkan.c.o
[ 28%] Building C object src/3rd_party/glfw/CMakeFiles/glfw.dir/src/window.c.o
[ 30%] Building C object src/3rd_party/glfw/CMakeFiles/glfw.dir/src/egl_context.c.o
[ 31%] Building C object src/3rd_party/glfw/CMakeFiles/glfw.dir/src/osmesa_context.c.o
[ 33%] Building C object src/3rd_party/glfw/CMakeFiles/glfw.dir/src/null_init.c.o
[ 34%] Building C object src/3rd_party/glfw/CMakeFiles/glfw.dir/src/null_monitor.c.o
[ 36%] Building C object src/3rd_party/glfw/CMakeFiles/glfw.dir/src/null_window.c.o
[ 37%] Building C object src/3rd_party/glfw/CMakeFiles/glfw.dir/src/null_joystick.c.o
[ 39%] Linking C static library libglfw.a
[ 39%] Built target glfw
[ 40%] Building C object src/3rd_party/lightmapper/CMakeFiles/lightmapper.dir/impl.c.o
[ 42%] Linking C static library liblightmapper.a
[ 42%] Built target lightmapper
[ 43%] Building C object src/3rd_party/mattiasgustavsson_libs/CMakeFiles/mattiasgustavsson_libs.dir/impl.c.o
[ 45%] Linking C static library libmattiasgustavsson_libs.a
[ 45%] Built target mattiasgustavsson_libs
[ 46%] Building C object src/3rd_party/miniz/CMakeFiles/miniz.dir/miniz.c.o
[ 48%] Linking C static library libminiz.a
[ 48%] Built target miniz
[ 50%] Building C object src/3rd_party/parson/CMakeFiles/parson.dir/parson.c.o
[ 51%] Linking C static library libparson.a
[ 51%] Built target parson
[ 53%] Building C object src/3rd_party/sokol/CMakeFiles/sokol.dir/impl.c.o
In file included from /Users/rblath/Projects/GitHub/Open-Golf/src/3rd_party/sokol/impl.c:4:
/Users/rblath/Projects/GitHub/Open-Golf/src/3rd_party/sokol/sokol_gfx.h:2421:2: error: "Please select a backend with SOKOL_GLCORE33, SOKOL_GLES2, SOKOL_GLES3, SOKOL_D3D11, SOKOL_METAL, SOKOL_WGPU or SOKOL_DUMMY_BACKEND"
#error "Please select a backend with SOKOL_GLCORE33, SOKOL_GLES2, SOKOL_GLES3, SOKOL_D3D11, SOKOL_METAL, SOKOL_WGPU or SOKOL_DUMMY_BACKEND"
^
/Users/rblath/Projects/GitHub/Open-Golf/src/3rd_party/sokol/sokol_gfx.h:3895:5: error: unknown type name '_sg_buffer_t'; did you mean 'sg_buffer'?
_sg_buffer_t* buffers;
^
/Users/rblath/Projects/GitHub/Open-Golf/src/3rd_party/sokol/sokol_gfx.h:628:45: note: 'sg_buffer' declared here
typedef struct sg_buffer { uint32_t id; } sg_buffer;
^
/Users/rblath/Projects/GitHub/Open-Golf/src/3rd_party/sokol/sokol_gfx.h:3896:5: error: unknown type name '_sg_image_t'; did you mean 'sg_image'?
_sg_image_t* images;
^
/Users/rblath/Projects/GitHub/Open-Golf/src/3rd_party/sokol/sokol_gfx.h:629:45: note: 'sg_image' declared here
typedef struct sg_image { uint32_t id; } sg_image;
^
/Users/rblath/Projects/GitHub/Open-Golf/src/3rd_party/sokol/sokol_gfx.h:3897:5: error: unknown type name '_sg_shader_t'; did you mean 'sg_shader'?
_sg_shader_t* shaders;
^
/Users/rblath/Projects/GitHub/Open-Golf/src/3rd_party/sokol/sokol_gfx.h:630:45: note: 'sg_shader' declared here
typedef struct sg_shader { uint32_t id; } sg_shader;
^
/Users/rblath/Projects/GitHub/Open-Golf/src/3rd_party/sokol/sokol_gfx.h:3898:5: error: unknown type name '_sg_pipeline_t'; did you mean 'sg_pipeline'?
_sg_pipeline_t* pipelines;
^
/Users/rblath/Projects/GitHub/Open-Golf/src/3rd_party/sokol/sokol_gfx.h:631:45: note: 'sg_pipeline' declared here
typedef struct sg_pipeline { uint32_t id; } sg_pipeline;
^
/Users/rblath/Projects/GitHub/Open-Golf/src/3rd_party/sokol/sokol_gfx.h:3899:5: error: unknown type name '_sg_pass_t'
_sg_pass_t* passes;
^
/Users/rblath/Projects/GitHub/Open-Golf/src/3rd_party/sokol/sokol_gfx.h:3900:5: error: unknown type name '_sg_context_t'; did you mean 'sg_context'?
_sg_context_t* contexts;
^
/Users/rblath/Projects/GitHub/Open-Golf/src/3rd_party/sokol/sokol_gfx.h:633:45: note: 'sg_context' declared here
typedef struct sg_context { uint32_t id; } sg_context;
^
/Users/rblath/Projects/GitHub/Open-Golf/src/3rd_party/sokol/sokol_gfx.h:12715:6: error: ("INVALID BACKEND");
#error("INVALID BACKEND");
^
/Users/rblath/Projects/GitHub/Open-Golf/src/3rd_party/sokol/sokol_gfx.h:12731:6: error: ("INVALID BACKEND");
#error("INVALID BACKEND");
^
/Users/rblath/Projects/GitHub/Open-Golf/src/3rd_party/sokol/sokol_gfx.h:12747:6: error: ("INVALID BACKEND");
#error("INVALID BACKEND");
^
/Users/rblath/Projects/GitHub/Open-Golf/src/3rd_party/sokol/sokol_gfx.h:12751:41: error: unknown type name '_sg_context_t'; did you mean 'sg_context'?
static inline void _sg_activate_context(_sg_context_t* ctx) {
^
/Users/rblath/Projects/GitHub/Open-Golf/src/3rd_party/sokol/sokol_gfx.h:633:45: note: 'sg_context' declared here
typedef struct sg_context { uint32_t id; } sg_context;
^
/Users/rblath/Projects/GitHub/Open-Golf/src/3rd_party/sokol/sokol_gfx.h:12763:6: error: ("INVALID BACKEND");
#error("INVALID BACKEND");
^
/Users/rblath/Projects/GitHub/Open-Golf/src/3rd_party/sokol/sokol_gfx.h:12767:52: error: unknown type name '_sg_context_t'; did you mean 'sg_context'?
static inline sg_resource_state _sg_create_context(_sg_context_t* ctx) {
^
/Users/rblath/Projects/GitHub/Open-Golf/src/3rd_party/sokol/sokol_gfx.h:633:45: note: 'sg_context' declared here
typedef struct sg_context { uint32_t id; } sg_context;
^
/Users/rblath/Projects/GitHub/Open-Golf/src/3rd_party/sokol/sokol_gfx.h:12779:6: error: ("INVALID BACKEND");
#error("INVALID BACKEND");
^
/Users/rblath/Projects/GitHub/Open-Golf/src/3rd_party/sokol/sokol_gfx.h:12783:40: error: unknown type name '_sg_context_t'; did you mean 'sg_context'?
static inline void _sg_destroy_context(_sg_context_t* ctx) {
^
/Users/rblath/Projects/GitHub/Open-Golf/src/3rd_party/sokol/sokol_gfx.h:633:45: note: 'sg_context' declared here
typedef struct sg_context { uint32_t id; } sg_context;
^
/Users/rblath/Projects/GitHub/Open-Golf/src/3rd_party/sokol/sokol_gfx.h:12795:6: error: ("INVALID BACKEND");
#error("INVALID BACKEND");
^
/Users/rblath/Projects/GitHub/Open-Golf/src/3rd_party/sokol/sokol_gfx.h:12799:51: error: unknown type name '_sg_buffer_t'; did you mean 'sg_buffer'?
static inline sg_resource_state _sg_create_buffer(_sg_buffer_t* buf, const sg_buffer_desc* desc) {
^
/Users/rblath/Projects/GitHub/Open-Golf/src/3rd_party/sokol/sokol_gfx.h:628:45: note: 'sg_buffer' declared here
typedef struct sg_buffer { uint32_t id; } sg_buffer;
^
/Users/rblath/Projects/GitHub/Open-Golf/src/3rd_party/sokol/sokol_gfx.h:12811:6: error: ("INVALID BACKEND");
#error("INVALID BACKEND");
^
/Users/rblath/Projects/GitHub/Open-Golf/src/3rd_party/sokol/sokol_gfx.h:12815:39: error: unknown type name '_sg_buffer_t'; did you mean 'sg_buffer'?
static inline void _sg_destroy_buffer(_sg_buffer_t* buf) {
^
/Users/rblath/Projects/GitHub/Open-Golf/src/3rd_party/sokol/sokol_gfx.h:628:45: note: 'sg_buffer' declared here
typedef struct sg_buffer { uint32_t id; } sg_buffer;
^
fatal error: too many errors emitted, stopping now [-ferror-limit=]
20 errors generated.
make[2]: *** [src/3rd_party/sokol/CMakeFiles/sokol.dir/impl.c.o] Error 1
make[1]: *** [src/3rd_party/sokol/CMakeFiles/sokol.dir/all] Error 2
make: *** [all] Error 2

I don't think the project has osx support

commented

Well, there is a build-osx.sh script included and the finding may help to correct an error.

well, yeah, but it seems like it errors out because there is no backend for osx.
So it's most likely intentional, although osx support would be nice!

/Users/rblath/Projects/GitHub/Open-Golf/src/3rd_party/sokol/sokol_gfx.h:12715:6: error: ("INVALID BACKEND");

Although you should try building it for emscripten

commented

You are right, the implementation file for sokol (src/3rd_party/sokol/impl.c) seems to be written with WIN32 in mind. Defining SOKOL_GLCORE33 instead of SOKOL_WIN32_NO_GL_LOADER fixes the error but chokes on the macOS Objective-C Framework. So there is more work to be done for macOS.

#define SOKOL_WIN32_NO_GL_LOADER
#define SOKOL_IMPL
#include "sokol/sokol_audio.h"
#include "sokol/sokol_gfx.h"
#include "sokol/sokol_time.h"

#define SOKOL_WIN32_FORCE_MAIN
#include "sokol/sokol_app.h"
#include "sokol/sokol_glue.h"

#define CIMGUI_DEFINE_ENUMS_AND_STRUCTS
#include "cimgui/cimgui.h"

#define SOKOL_IMGUI_IMPL
#include "sokol/sokol_imgui.h"


[...]
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX12.1.sdk/System/Library/Frameworks/Foundation.framework/Headers/NSObjCRuntime.h:523:1: error: expected identifier or '('
@Class NSString, Protocol;

Sokol itself does support macOS.

I forgot I had the build/build-osx.sh file still there. I can look at tonight and should be able to get it working again.

The macOS build should be fixed now!

Check out this commit for details: 30b10d6