Cannot build GDExtension C++ library for for Android #1700
Copy link
Copy link
Closed
Labels
bugThis has been identified as a bugThis has been identified as a bugplatform:androidtopic:buildsystemRelated to the buildsystem or CI setupRelated to the buildsystem or CI setuptopic:gdextensionThis relates to the new Godot 4 extension implementationThis relates to the new Godot 4 extension implementation
Description
Tested versions
Godot 4.3
System information
Mac OS 15
Issue description
Cannot build Godot native library (so) for android on Mac OS 15, using Godot 4.3.
I followed these steps: Compiling for Android — Godot Engine (stable) documentation in English
The SDK and NDK seems to be setup well. Building progresses until linking, where this issue happens:
Linking Shared Library solitaire/bin/libbachey.android.template_debug.arm64.so ...
ld: error: unknown argument '-dynamic', did you mean '-Bdynamic'
ld: error: unknown argument '-dylib'
ld: error: unknown argument '-arch'
ld: error: unknown argument '-platform_version'
ld: error: unable to find library -lto_library
ld: error: cannot open /Users/bacsigabor/Library/Android/sdk/ndk/23.2.8568313/toolchains/llvm/prebuilt/darwin-x86_64/lib/libLTO.dylib: No such file or directory
ld: error: cannot open x86_64: No such file or directory
ld: error: cannot open macos: No such file or directory
ld: error: cannot open 15.0.0: No such file or directory
ld: error: cannot open 0.0.0: No such file or directory
ld: error: unable to find library -lc++
ld: error: unable to find library -lSystem
clang-12: error: linker command failed with exit code 1 (use -v to see invocation)
scons: *** [solitaire/bin/libbachey.android.template_debug.arm64.so] Error 1
scons: building terminated because of errors.
bacsigabor@Mac godot-solitaire %
I tried the setup steps for windows, but similarly Scons fails at linking:
solitaire\bin\libbachey.android.template_debug.arm64.so ...
=====
lld: error: unable to find library -lc++
lld: error: unable to find library -lmingw32
lld: error: unable to find library -lgcc_s
lld: error: unable to find library -lgcc
lld: error: unable to find library -lmoldname
lld: error: unable to find library -lmingwex
lld: error: unable to find library -lmsvcrt
lld: error: unable to find library -ladvapi32
lld: error: unable to find library -lshell32
lld: error: unable to find library -luser32
lld: error: unable to find library -lkernel32
lld: error: unable to find library -lmingw32
lld: error: unable to find library -lgcc_s
lld: error: unable to find library -lgcc
lld: error: unable to find library -lmoldname
lld: error: unable to find library -lmingwex
lld: error: unable to find library -lmsvcrt
lld: error: unable to find library -lkernel32
clang++: error: linker command failed with exit code 1 (use -v to see invocation)
Why? What could I miss? Are there other important settings than ANDROID_HOME environment variable or do I need additional step for the SConstruct file?
Steps to reproduce
Follow Android SDK/NDK setup steps, build GDNative with scons and notice these errors
Minimal reproduction project (MRP)
SCons file:
#!/usr/bin/env python
import os
import sys
env = SConscript("godot-cpp/SConstruct")
# For reference:
# - CCFLAGS are compilation flags shared between C and C++
# - CFLAGS are for C-specific compilation flags
# - CXXFLAGS are for C++-specific compilation flags
# - CPPFLAGS are for pre-processor flags
# - CPPDEFINES are for pre-processor defines
# - LINKFLAGS are for linking flags
# tweak this if you want to use different folders, or more folders, to store your source code in.
env.Append(CPPPATH=["src/"])
sources = Glob("src/*.cpp")
AddOption(
'--opt',
action='store_true',
help='optimise',
default=False)
if GetOption('opt'):
env.Append(CXXFLAGS=['-O3'])
env['LINKFLAGS'] = []
else:
env.Append(CXXFLAGS=['-g', '-O0'])
env['LINKFLAGS'] = ['-g']
0]) + " - >" + str(item[1]))
if env["platform"] == "macos":
library = env.SharedLibrary(
"solitaire/bin/libbachey.{}.{}.framework/libbachey.{}.{}".format(
env["platform"], env["target"], env["platform"], env["target"]
),
source=sources,
)
else:
library = env.SharedLibrary(
"solitaire/bin/libbachey{}{}".format(env["suffix"], env["SHLIBSUFFIX"]),
source=sources,
)
Default(library)
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
bugThis has been identified as a bugThis has been identified as a bugplatform:androidtopic:buildsystemRelated to the buildsystem or CI setupRelated to the buildsystem or CI setuptopic:gdextensionThis relates to the new Godot 4 extension implementationThis relates to the new Godot 4 extension implementation
Activity
[-]Cannot build GDNative C++ library for for Android[/-][+]Cannot build GDExtension C++ library for for Android[/+]akien-mga commentedon Feb 4, 2025
Moved to godot-cpp as it's not a Godot build issue but a godot-cpp one.
What commands are you using to compile for the two logs you shared?
The first one includes options which are macOS specific, and the second one includes options which are specific to Windows builds, it doesn't make much sense that they would be used for the Android platform. Are you copying code from the godot-cpp buildsystem for these platforms in the Android SCons tool?
Stellarica-Interactive commentedon Feb 4, 2025
For both output I was in the root of the project, which has a structure of:
-godot-cpp // The godot-cpp checked out as a submodule at latest from master
-solitaire //The godot project folder
-src // The native cpp headers/sources
-Sconstruct // scons file with the content pasted above.
and I ran this simple command for both platforms:
scons platform=androidI was hoping I could get this working at least on one platform, but let's focus on Mac.
The goal is that I want to export an android .so library, so I can build for Android. Exporting the game works except the problem that it does not find my native library (which I cannot build as per my logs.) The command should build the native scripts and create a .so in my godot project/bin folder.
I followed the godot cpp example as a reference
And it actually works for macos, but not for android (also followed the steps from the documentation above)
NDK: 23.2.8568313 (as in documentation)
Downloaded the latest Android SDK package (command line tools)
I followed every step of the documentation and also set ANDROID_HOME: /Users/bacsigabor/android-sdk
(Where I extracted the downloaded SDK)
Not sure if this answers the question, but please let me know if you need more information. Thank you!
EDIT: switched to 4.3 branch on godot-cpp, same result
Stellarica-Interactive commentedon Feb 4, 2025
Got the solution,
This should not be for Android builds. Now the library builds well.
enetheru commentedon Feb 7, 2025
@BacheyG Does that mean you can close this report?