Repository navigation
Closed
Labels
Description
Godot version
4.4
godot-cpp version
System information
Ubuntu
Issue description
Hi,
I'm using osxcross to compile godot-cpp for MacOS and iOS. I just upgraded from Godot 4.3 (which was working fine) to 4.4 and I am getting this error:
CMake Error at cmake/macos.cmake:22 (find_library):
Could not find COCOA_LIBRARY using the following names: Cocoa
Call Stack (most recent call first):
cmake/godotcpp.cmake:25 (include)
CMakeLists.txt:43 (include)
This is my compile command:
AR=x86_64-apple-$OSXCROSS_TARGET-ar \
CC=x86_64-apple-$OSXCROSS_TARGET-clang \
CODESIGN_ALLOCATE=$OSXCROSS_ROOT/target/bin/x86_64-apple-$OSXCROSS_TARGET-codesign_allocate \
CPLUS_INCLUDE_PATH=$OSXCROSS_ROOT/target/include \
CXX=x86_64-apple-$OSXCROSS_TARGET-clang++ \
C_INCLUDE_PATH=$OSXCROSS_ROOT/target/include \
HOST=x86_64-apple-$OSXCROSS_TARGET \
LIBRARY_PATH=$OSXCROSS_ROOT/target/libx86_64 \
PATH=$OSXCROSS_ROOT/target/bin:$PATH \
RANLIB=x86_64-apple-$OSXCROSS_TARGET-ranlib \
x86_64-apple-$OSXCROSS_TARGET-cmake \
-DCMAKE_BUILD_TYPE=Release \
-DCMAKE_CXX_FLAGS="-Ofast" \
-DCMAKE_C_FLAGS="-Ofast" \
-DCMAKE_INSTALL_DOCDIR=/tmp/godotcpp/build_MACOS_X86_64 \
-DCMAKE_INSTALL_LIBDIR=libx86_64 \
-DCMAKE_INSTALL_MANDIR=/tmp/godotcpp/build_MACOS_X86_64 \
-DCMAKE_INSTALL_PREFIX=$OSXCROSS_ROOT/target \
-DAPPLE=1 \
-DGODOT_CPP_WARNING_AS_ERROR=OFF \
-DGODOT_CPP_SYSTEM_HEADERS=ON \
-DFLOAT_PRECISION=single \
-B /tmp/godotcpp/build_MACOS_X86_64 \
/tmp/godotcpp
I can see the Cocoa framework is installed:
$ tree $SDKROOT/System/Library/Frameworks/Cocoa.framework
/opt/osxcross/target/SDK/MacOSX15.1.sdk/System/Library/Frameworks/Cocoa.framework
|-- Cocoa.tbd -> Versions/Current/Cocoa.tbd
|-- Headers -> Versions/Current/Headers
|-- Modules -> Versions/Current/Modules
`-- Versions
|-- A
| |-- Cocoa.tbd
| |-- Headers
| | `-- Cocoa.h
| `-- Modules
| `-- module.modulemap
`-- Current -> A
7 directories, 4 files
These are my environment variables:
$ env | grep -i osx
OSXCROSS_LIBLTO_PATH=
OSXCROSS_BUILD_DIR=/opt/osxcross/build
OSXCROSS_PATCH_DIR=/opt/osxcross/build/../patches
OSXCROSS_LINKER_VERSION=711
SDKROOT=/opt/osxcross/target/SDK/MacOSX15.1.sdk
OSXCROSS_OSX_VERSION_MIN=10.13
OSXCROSS_TARBALL_DIR=/opt/osxcross/build/../tarballs
OSXCROSS_DIR_SDK_TOOLS=/opt/osxcross/target/bin/../SDK/MacOSX15.1.sdk/../tools
OSXCROSS_BASE_DIR=/opt/osxcross/build/..
OSXCROSS_SDK_VERSION=15.1
OSXCROSS_VERSION=1.5
OSXCROSS_TARGET=darwin24.1
OSXCROSS_SDK_DIR=/opt/osxcross/target/bin/../SDK/MacOSX15.1.sdk/..
OSXCROSS_TARGET_DIR=/opt/osxcross/target/bin/..
IOS_TOOLCHAIN_ROOT=/opt/osxcross/build/cctools-port/usage_examples/ios_toolchain/target
OSXCROSS_SDK=/opt/osxcross/target/bin/../SDK/MacOSX15.1.sdk
MACOS_SDK=MacOSX15.1.sdk
OSXCROSS_ROOT=/opt/osxcross
OSXCROSS_CCTOOLS_PATH=/opt/osxcross/target/bin
Any suggestions?
Thanks
Steps to reproduce
Install Osxcross and try cross-compiling Godot-cpp from Ubuntu/Debian
Minimal reproduction project
N/A
Activity
enetheru commentedon Mar 22, 2025
ooh nice, ok so I have no experience with OSXCROSS, there is no cmake code explicitly catering for it, but there shouldnt be a need for that.
Why u no build a toolchain file to hand to cmake to reduce the amount of command line?
I notice that you don't specify
CMAKE_SYSROOT, or theCMAKE_FIND_ROOT_PATHThis might be useful to read: https://stackoverflow.com/questions/63929668/cmake-cross-compilation-with-sysroot-returns-wrong-include-paths
aswell as this: https://cmake.org/cmake/help/latest/manual/cmake-toolchains.7.html#id8
If I can setup a test environment I will do more, but I dont have a physical or virtual linux machine on hand to test with, so it might take me a bit of time to get to this.
In the meantime if you figure anything out please let me know if there is anything I need to change. Cheers.
kroketio commentedon Mar 23, 2025
-DCMAKE_TOOLCHAIN_FILE=/root/osxcross/target/toolchain.cmakeOSXCROSS_HOSTenvI also had to patch
/root/osxcross/target/bin/x86_64-apple-darwin23.6-ldbut thats a different story./root/osxcross/target/toolchain.cmakefatduckling commentedon Mar 23, 2025
Thanks @kroketio I'll try this.
But after further investigation, do we even need the Cocoa library?
I realise it's not even used, and it's only failing because of the
REQUIREDclause in thefind_library.Removing all instances of the Cocoa dependencies in the cmake file (or even just the REQUIRED keyword) makes the godot-cpp library compile just fine and the game launches fine on macOS without it.
Also, it's just a header-only library I think, so we don't need to use
find_libraryhere I believe.kroketio commentedon Mar 23, 2025
cocoa is there because scons links it too
https://github.com/godotengine/godot-cpp/blob/f08e781b0ba3e45264d7d40e5d6debaa0d838383/tools/macos.py#L66:L72
I dunno why it is needed though, I am not very into Apple stuff.
fatduckling commentedon Mar 30, 2025
Thanks very much @dsnopek @bruvzg
Can we merge this to 4.4.1?
dsnopek commentedon Mar 31, 2025
I've marked it for cherry-picking, so it should it in the next batch to merge into the
4.4branch