You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[Bug](build): missing '-shared' flag causes 'undefined symbol: main' linker error when cross-compiling #3363
I wanted to make a PR but I'm new on building with mac and I don't know whether adding -shared will break linux platform (not free to test on linux atm)
On macOS that prints roughly clang++ -bundle -undefined dynamic_lookup, on
Linux g++ -pthread -shared ....
So on macOS the link becomes NDK clang++ -bundle -undefined dynamic_lookup ...
On Linux -shared survives, which is why the platform difference exists. That also answers your question: adding -shared to LDFLAGS won't break Linux, it's just a duplicate flag there.
But it fixes only the kivy recipe, and LDFLAGS also feeds autoconf-style link tests in other recipes.
A more targeted fix could be in in Arch.get_env():
and the matching line in the kivy recipe next to the existing LDSHARED
override:
env['LDCXXSHARED'] =env['CXX'] +' -shared'
This is host-independent, so it should be a no-op on Linux CI while fixing macOS, and it covers every recipe with C++ extensions rather than just kivy.
Activity
T-Dynamos commentedon Aug 4, 2026
It's a general problem with cross compiling for Android from Mac.
Build system assumes we are building for mac and injects mac related flags. This works fine on linux as Android is effectively a linux.
AndreMiras commentedon Aug 31, 2026
Thanks for reporting.
I think the root cause is that p4a never sets
LDCXXSHARED, onlyLDSHARED.You can see it on your machine:
On macOS that prints roughly
clang++ -bundle -undefined dynamic_lookup, onLinux
g++ -pthread -shared ....So on macOS the link becomes NDK
clang++ -bundle -undefined dynamic_lookup ...On Linux
-sharedsurvives, which is why the platform difference exists. That also answers your question: adding-sharedtoLDFLAGSwon't break Linux, it's just a duplicate flag there.But it fixes only the kivy recipe, and
LDFLAGSalso feeds autoconf-style link tests in other recipes.A more targeted fix could be in in
Arch.get_env():and the matching line in the kivy recipe next to the existing
LDSHAREDoverride:
This is host-independent, so it should be a no-op on Linux CI while fixing macOS, and it covers every recipe with C++ extensions rather than just kivy.
I'll open a PR to address
Edit: #3371
🐛 Fix C++ shared linker configuration, fixes kivy#3363
Merge pull request kivy#3371 from kivy/fix/cpp_shared_linker