Open CoffeeCoder1 opened 3 months ago
@CoffeeCoder1 Thanks for the PR. Will it work on Mac now? I also need this for Mac eventually.
@samsface
Will it work on Mac now? I also need this for Mac eventually.
The updates to libpd should at least fix some of the problems with building on Mac. I was able to get it to at least build for arm64 when I was experimenting with it earlier, and I think a few modifications to some of the CMakeLists files should make universal builds possible.
@CoffeeCoder1 If it helps, I added this line to a Godot 3.X C++ extension to build fat binaries on MacOS: https://github.com/samsface/godot-steam-api/blob/ceb3cb365bab19783cdd0bf1e420f39e63b725fc/CMakeLists.txt#L66
@samsface
I added this line to a Godot 3.X C++ extension to build fat binaries on MacOS
That's probably pretty similar to what I will have to do. For whatever reason, if I just do that the linker throws an error, but it may just be something weird about my environment that I have to sort out.
Have you updated the submodule? I didn't submit a PR to do that because it requires an update to the fork the submodule points to (which I do not have the ability to create a pull request for because I am not a collaborator on the libpd repo) and this repo.
@samsface I was able to create a pull request to merge the new changes from upstream (https://github.com/samsface/libpd/pull/1) by creating a fork of libpd and creating a PR from there. Once you merge that, I should be able to create another PR to update the submodule here.
I should probably try merge my PR into libpd itself, it fixes how the header import paths work but that repo seemed so dead I use my own fork here.
I got a universal build to work! The problem ended up just being that the multiple architectures were being set after the libraries were included, so the libraries were only being built for arm64 targets and the linking failed.
I'll reopen this issue since it hasn't been resolved yet, but it should be the only thing preventing MacOS builds from working now. To get the build working I had to merge upstream libpd into my local submodule, so actions builds will fail for now.
Hello, I'd like to get this running on my mac as well. I'm not super fluent in C++, or git submodules for that matter. @CoffeeCoder1 can you explain to me how to get the universal build working on my end? Do I need to replace the libpd submodule with a different fork? What changes did you do so that the architectures are set up before the libraries were included?
Here are the errors I get when I build:
/Users/eric/Workspace/godot-pure-data/lib/libpd/pure-data/src/x_file.c:603:5: error: call to undeclared library function 'alloca' with type 'void *(unsigned long)'; ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration]
ALLOCA(unsigned char, buf, outc, 100);
^
/Users/eric/Workspace/godot-pure-data/lib/libpd/pure-data/src/m_private_utils.h:65:13: note: expanded from macro 'ALLOCA'
alloca((nmemb) * sizeof(type)) : getbytes((nmemb) * sizeof(type))))
^
/Users/eric/Workspace/godot-pure-data/lib/libpd/pure-data/src/x_file.c:603:5: note: include the header <stdlib.h> or explicitly provide a declaration for 'alloca'
/Users/eric/Workspace/godot-pure-data/lib/libpd/pure-data/src/m_private_utils.h:65:13: note: expanded from macro 'ALLOCA'
alloca((nmemb) * sizeof(type)) : getbytes((nmemb) * sizeof(type))))
^
1 warning and 1 error generated.
make[2]: *** [lib/libpd/CMakeFiles/libpd_static.dir/pure-data/src/x_file.c.o] Error 1
make[1]: *** [lib/libpd/CMakeFiles/libpd_static.dir/all] Error 2
make: *** [all] Error 2
Edit: I got much further along by swapping out the libpd submodule with the official repo. However now this is the error I'm getting:
/Users/eric/Workspace/godot-pure-data/src/pure_data_audio_stream_player.cpp:7:10: fatal error: 'z_libpd.h' file not found
#include "z_libpd.h"
^~~~~~~~~~~
1 error generated.
make[2]: *** [CMakeFiles/pd-godot.dir/src/pure_data_audio_stream_player.cpp.o] Error 1
make[1]: *** [CMakeFiles/pd-godot.dir/all] Error 2
make: *** [all] Error 2
I'm guessing this is because of the bug where the architectures are set after the libraries were included, but I have no idea how to fix that.
@MaxKablaam The process to get it working should be pretty simple.
git clone --recurse-submodules https://github.com/CoffeeCoder1/godot-pure-data.git
git switch macos
This can also be done by adding my fork to your existing clone as a remote.
git remote add coffeecoder1-fork https://github.com/CoffeeCoder1/godot-pure-data.git
git remote update
git switch macos
cd lib/libpd
git remote add upstream https://github.com/libpd/libpd.git
git remote update
git merge upstream/master
Builds should work now!
@CoffeeCoder1 Thank you for the thorough instructions, it works, I got it to build, but I think I might be missing some steps.
I have a folder called /build
, and in there I init cmake with cmake ..
. Then I build with make
. Does this compile everything? Am I missing a step? It still doesn't work in the demo project. Shouldn't there be an SConstruct file? Or is everything being configured in CMake?
@MaxKablaam I have just been using the dev.sh
script in the root of the repo to build. I haven't gotten the demo project in the repo working yet, but I made my own pretty simple test project for my own testing, which I'll stick in a repo in a second. The dylib isn't in the gdextension file yet, so for now you will need to add it manually if you want to use the library (my test project has these changes already so it should just work out of the box).
@MaxKablaam Got my test project uploaded at CoffeeCoder1/godot-pure-data-test-project.
Wow, thanks! That simplifies things for me a lot. Test project works flawlessly.
@samsface Any updates on this? libpd seems to have been pretty active lately, so there's a decent chance they'll get to your PR pretty quickly.
I'm working on getting this working on MacOS, and https://github.com/libpd/libpd/commit/4b8a840011facde8ef615e75b612454cae9cf31e appears to fix a problem that prevents it from building on MacOS.