travisvroman / kohi

A game engine made as part of the Kohi Game Engine series on YouTube (and Twitch!), where we make a game engine from the ground up using C and Vulkan.
https://kohiengine.com
Apache License 2.0
946 stars 92 forks source link

Unable to build on Mac m2 air #224

Closed ozzyozbourne closed 21 minutes ago

ozzyozbourne commented 3 months ago
Screenshot 2024-04-19 at 2 30 26 AM

Describe the bug A clear and concise description of what the bug is.

To Reproduce Steps to reproduce the behavior:

  1. Getting error on runing build-debug.sh or build-release.sh
ozzyozbourne commented 3 months ago

Hello Travis, I'm not sure why this is happening. Am I missing some library? Although I have added all the necessary dependencies mentioned for macOS, I'm running build-debug.sh from the main branch.

P.S. I have been enjoying the Kohi game engine series immensely. Keep up the good work, brother. Thanks

bkamras09 commented 2 months ago

@ozzyozbourne I am on an M3 MBP and I also experienced this issue. I don't know if this is the correct path forward, but I wrote my own kthread_wait function as mentioned in this issue:

https://github.com/travisvroman/kohi/issues/222

Here is my version. Note that I don't really know if this is the right way to write the function as I haven't contributed to this project and I don't write C at work.

b8 kthread_wait(kthread* thread) {
    if (!thread) {
        return false;
    }

    while (true) {
        if (thread->work_queue.element_count == 0) {
            break;
        }
    }

    return true;
}

I can now get the project to compile, but only when executing ./build-debug.sh. When executing ./build-release.sh, I get this error:

engine/src/renderer/renderer_frontend.c:501:8: error: no member named 'module_watch_ids' in 'struct shader'
    s->module_watch_ids = kallocate(sizeof(u32) * config->stage_count, MEMORY_TAG_ARRAY);
    ~  ^
1 error generated.
make: *** [obj/engine/src/renderer/renderer_frontend.c.o] Error 1

When building with ./build-debug.sh and running ./testbed, I get this error despite having Vulkan installed:

[ERROR]: Error opening library: dlopen(libvulkan_renderer.dylib, 0x0002): Library not loaded: @rpath/libvulkan.1.dylib
  Referenced from: <3D97920A-53AB-32EA-AFF7-FDA3F6E76247> /Users/briankamras/Documents/GitHub/kohi/bin/libvulkan_renderer.dylib
  Reason: tried: './libvulkan.1.dylib' (no such file)
[FATAL]: Could not create application!
travisvroman commented 21 minutes ago

@ozzyozbourne Thanks for submitting this!

Catching up on issues - apologies for the delay! I had to dig back a bit for this since it was technically resolved a while ago. #222 was as well.

Anyway, ultimately the issue was the fact that kthread_wait was never defined on the mac platform (nor linux seemingly) at the time this was written up. Anything version 0.6 and before would have been wrong here for those platforms. You'll need to use 0.7.0 or newer and this is fixed. For mac specifically, you'll want to use 0.7.1 or newer.

Closing this.