Closed skrshe closed 4 months ago
I'm currently working on a solution because I would like to use this template on my mac & pc and I don't mind creating a pull request.
@karl-zylinski I know I pinged you in twitter about this but I'll ask you this here for visibility so people can know if they should bother you about this.
😸
I'd gladly accept a PR that introduces linux & mac support.
I think it should be possible to do it in a quite minimal way where you use a when ODIN_OS == .Linux
block in main_hot_reload.odin
to choose the file to load. You'll also need to make .sh version of the .bat scripts.
Not sure why it didn't work for @skrshe
Also note: I just submitted some code that combined the 4 .bat scripts into just 2 and also moved some stuff around in game.odin, you might want to pull that stuff before doing anything.
Seems like unloading libraries on the mac is a bit more involved than I imagined, or at least this current setup where the raylib dll is a dependency.
The program keeps crashing on me when I reload the dll with errors from ObjectiveC complaining about GLFW 'classes' being already loaded & defined.
For instance:
objc[39464]: Class GLFWHelper is implemented in both /Users/sstefanov01/Documents/odin/odin-raylib-hot-reload-game-template/game_0.dll (0x10317d768) and /Users/sstefanov01/Documents/odin/odin-raylib-hot-reload-game-template/game_1.dll (0x1171ed768). One of the two will be used. Which one is undefined.
If anyone has a clue, I'm all ears.
I haven't ever tried to do this stuff on mac or linux (I develop on windows and only make release builds without hot reload on mac / linux).
However, googling this stuff does give a bunch of people having what I think is similar issues, some seem to have resolved them? Not sure: https://www.google.com/search?client=firefox-b-d&q=hot+reload+dynamic+library+mac
^ from my Discord. Seems like using install_name_tool to alter the ID of the dylib is the way to go. It doesn't matter that you get duplicate stuff between dylibs, since that's what I want anyways. game.exe keeps old game dylibs around since it can't just unload them, due to stuff like string literals (which may have ended up as a string inside some struct) and tracking allocator source code locations will be destroyed if you unload the old dylibs.
I have tried following your blog post on hot reloading, in linux, substituting
.dll
's for.so
's where ever needed but I ran in to troubles and gave up.Might try again soon.