Open gingerbeardman opened 1 year ago
Solved!
~/Library/Frameworks
cmake
found the up-to-date SDL2 at /Library/Frameworks
Next
❯ make
[ 1%] Linking CXX shared library libcrogine.dylib
ld: warning: ignoring file /Library/Frameworks/freetype.framework/freetype, file is universal (x86_64,i386) but does not contain the arm64 architecture: /Library/Frameworks/freetype.framework/freetype
Thanks for attempting this - macOS isn't really my area. Hitherto I've always installed all the external libs with brew and it's worked OK, but I've never attempted Apple Silicon or a universal binary. I'm led to believe brew installs are not universal.
I checked and freetype is universal, so... did some more digging.
Found an old file at /Library/Frameworks/freetype.framework
(why do I have all these ancient versions of frameworks!?)
And I've built it successfully!
[100%] Built target crogine
🥳
Fantastic! 😁
So, now I've built libcrogine.dylib
, how do I "build" the rest of macOS app?
I figure I can save time by just asking 👍
Have you seen macOS.md in the samples/golf folder? That has a run-down of building a bundle with cmake
No, I had not 🔰
On it...
It basically contains the full extent of my knowledge of building on macOS - I actually started writing it to remind myself how to do the existing builds each release... 😅
So close!
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
note: Run script build phase 'Generate CMakeFiles/ALL_BUILD' will be run during every build because the option to run the script phase "Based on dependency analysis" is unchecked. (in target 'ALL_BUILD' from project 'golf')
note: Run script build phase 'CMake PostBuild Rules' will be run during every build because the option to run the script phase "Based on dependency analysis" is unchecked. (in target 'install' from project 'golf')
** BUILD FAILED **
The following build commands failed:
Ld /Users/matt/Downloads/2023-02-23/crogine-golf-v1.10.0/samples/golf/build/build/golf.build/Release/Objects-normal/x86_64/Binary/golf normal x86_64 (in target 'golf' from project 'golf')
(1 failure)
Just to make sure, I'm doing:
cmake .. \
-D MACOS_BUNDLE=true \
-G Xcode \
-D CMAKE_C_COMPILER="/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/cc" \
-D CMAKE_CXX_COMPILER="/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/c++" \
-D CMAKE_OSX_ARCHITECTURES="arm64;x86_64"
and
sudo cmake --build . --config Release --target install
I've never used
-D CMAKE_C_COMPILER="/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/cc"
-D CMAKE_CXX_COMPILER="/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/c++"
personally, I let cmake find the compiler itself. These lines were added by someone else working on a mac build.
symbol(s) not found for architecture x86_64
Sounds like it's building the arm version, but not the x86_64 version so it fails when linking. I've never tried this before, so there may be a missing step when telling xcode/clang to build. If you omit the architecture define from cmake it'll probably compile but you'll have an arm-only version (or it might fail trying to link to universal libraries 😅)
Yeah, the feeling I get is that -D CMAKE_OSX_ARCHITECTURES="arm64;x86_64"
is not enough for universal build.
I have just built Apple silicon only version using cmake .. -D MACOS_BUNDLE=true -G Xcode
I've run out of time but I'll circle back soon to try again for a Universal build. If your other Mac builder has any ideas, I'm all ears.
Also, it's possible to build these in the cloud (maybe even through GitHub actions) which may be something to look into once we have this all nailed down.
Just added a quick change to macOS build doc, as #66
For build script/instructions see https://github.com/fallahn/crogine/issues/68#issuecomment-1468782756
Building 1.12.1 fails with the following error regarding MenuAvatars.cpp
Is this the llvm/clang issue you were referring to on Twitter?
** BUILD FAILED **
The following build commands failed:
CompileC /Users/matt/Downloads/2023-04-26/crogine/crogine-golf-v1.12.1/samples/golf/build/build/golf.build/Release/Objects-normal/arm64/MenuAvatars.o /Users/matt/Downloads/2023-04-26/crogine/crogine-golf-v1.12.1/samples/golf/src/golf/MenuAvatars.cpp normal arm64 c++ com.apple.compilers.llvm.clang.1_0.compiler (in target 'golf' from project 'golf')
(1 failure)
other possible errors from subsequent attempts
error: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/install_name_tool: no LC_RPATH load command with path: /Library/Frameworks found in: /usr/local/lib/libcrogine.dylib (for architecture arm64), required for specified option "-delete_rpath /Library/Frameworks"
My error was the lack of std::filesystem support - the actual error appears just before the ** BUILD FAILED **
line (and is missing from your post).
In hindsight this line in the CMake file is probably not helping (at least on newer versions of macOS). Increasing the value or outright omitting it may help with missing features.
Sadly still the same "BUILD FAILED" error.
You still haven't included the error message though 😁 The actual error will be further up the build output like this:
(this isn't the actual error, just one I, er, had laying around so to speak, as an example)
LOL, sorry.
/Users/matt/Downloads/2023-04-26/crogine/crogine-golf-v1.12.1/samples/golf/src/golf/MenuAvatars.cpp:1650:26: error:
'remove_all' is unavailable: introduced in macOS 10.15
std::filesystem::remove_all(path, ec);
^
In file included from /Users/matt/Downloads/2023-04-26/crogine/crogine-golf-v1.12.1/samples/golf/src/golf/MenuAvatars.cpp:50:
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX13.1.sdk/usr/include/c++/v1/filesystem:2246:44: note:
'remove_all' has been explicitly marked unavailable here
inline _LIBCPP_INLINE_VISIBILITY uintmax_t remove_all(const path& __p,
^
/Users/matt/Downloads/2023-04-26/crogine/crogine-golf-v1.12.1/samples/golf/src/golf/MenuAvatars.cpp:1650:37: error:
'path' is unavailable: introduced in macOS 10.15
std::filesystem::remove_all(path, ec);
^
In file included from /Users/matt/Downloads/2023-04-26/crogine/crogine-golf-v1.12.1/samples/golf/src/golf/MenuAvatars.cpp:50:
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX13.1.sdk/usr/include/c++/v1/filesystem:948:3: note:
'path' has been explicitly marked unavailable here
path(const _Source& __src, format = format::auto_format) {
^
/Users/matt/Downloads/2023-04-26/crogine/crogine-golf-v1.12.1/samples/golf/src/golf/MenuAvatars.cpp:1650:37: error:
'~path' is unavailable: introduced in macOS 10.15
std::filesystem::remove_all(path, ec);
^
In file included from /Users/matt/Downloads/2023-04-26/crogine/crogine-golf-v1.12.1/samples/golf/src/golf/MenuAvatars.cpp:50:
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX13.1.sdk/usr/include/c++/v1/filesystem:968:3: note:
'~path' has been explicitly marked unavailable here
~path() = default;
^
3 warnings and 3 errors generated.
Aha! Well that does explain what's going on - and is in fact the same lack of std::filesystem I suffer. Or rather, it has been suppressed because it wasn't introduced until 10.15, and we're apparently still trying to target below that.
This makes sense for me, because I'm still on 10.14 - however I'm not sure what's going on your end. If you modified the CMake file to target a higher version, it ought to work...
My best suggestion is:
Check the CMake file for the crogine library, it may also have the 10.14 target line - and comment it out
Double check the CMake file for golf and make sure the target line is commented out
Do a complete clean - delete the build directories for both the library and golf, and create new ones
Double check the XCode target - I think this was part of the configuration in macOS.md
? Make sure it's using a newer (or newest) version.
Try rebuilding.
D'oh! I had unzipped a fresh source and forgot to edit the CMake file again. Bumping it to 10.15 and it builds! I have updated my build script to automatically make that change.
BUT
I get a black screen rather than any 3D?
I'm using assets from from the latest Windows build.
Well. This is progress I guess? :)
Looks like a shader failed to compile - are there any errors in the console window?
Hm, well that's a different (mac specific, but thankfully trivial) error, and shouldn't be causing this. You can try a debug build to increase verbosity, but the game itself will probably run like toffee :)
Although I do have a bit of a sinking feeling... could you try changing this line from
cro::RenderTarget::Context ctx(static_cast<std::uint32_t>(texSize.x), static_cast<std::uint32_t>(texSize.y), true, true, false, samples);
to
cro::RenderTarget::Context ctx(static_cast<std::uint32_t>(texSize.x), static_cast<std::uint32_t>(texSize.y), true, false, false, samples);
(the second true
to false
)?
I can see!
So... what's going on?
BUT
It's some groundwork I was doing for a future update involving weather - so not currently strictly necessary. To fix the latter you'll need to do the same thing on this line. (ie set it to false).
No idea how I'll debug this without a mac :(
Changing that second line got things going in-game.
The only things I can suggest are macOS in a VM (if your Mac is capable of running newer but you're holding back, just install newer in a VM) or cloud renting a Mac for short periods (monthly?) or pick up a cheap old Mac (even 10 year old old laptops can run Catalina). Of course this is easy for me to suggest :)
Hm. I've tried VMs on windows and they were slow as feh. It never occurred to me I could run a VM on the mac :)
I don't really like to mess with mine because actually it's just there to run the software for my DJ equipment. Building software on it was a kind of experiment which has since spiralled out of scope 🤦♀️
And there's no such thing as a cheap mac :P
OK the build is working now on Sonoma (? whatever the latest is) with mac hardware. Except when built as a bundle it won't run with some codesigning error. Maybe you'll have some luck - use the 1.14.1 tag 👍
I can only see 1.14 tag and it doesn't build
edit: ah i was looking at branches, will look into tags
[ 96%] Building CXX object CMakeFiles/crogine.dir/src/audio/OpenALImpl.cpp.o
error: error opening 'CMakeFiles/crogine.dir/src/audio/OpenALImpl.cpp.o.d': No such file or directory
1 error generated.
make[2]: *** [CMakeFiles/crogine.dir/src/audio/OpenALImpl.cpp.o] Error 1
make[1]: *** [CMakeFiles/crogine.dir/all] Error 2
make: *** [all] Error 2
Hurrah!