Skip to content

[Bug](build): missing '-shared' flag causes 'undefined symbol: main' linker error when cross-compiling #3363

Description

@kengoon

OS: MacOS 26.6 (M chip)
Python: 3.14
Kivy: 3.0 (master)

when p4a starts building kivy 3.0 it fails with this error:

clang++: warning: argument unused during compilation: '-bundle' [-Wunused-command-line-argument]
clang++: warning: argument unused during compilation: '-undefined dynamic_lookup' [-Wunused-command-line-argument]
ld.lld: error: undefined symbol: main
>>> referenced by crtbegin.c
>>>               /Users/kengoon/.buildozer/android/platform/android-ndk-r28c/toolchains/llvm/prebuilt/darwin-x86_64/bin/../sysroot/usr/lib/aarch64-linux-android/24/crtbegin_dynamic.o:(_start_main)
>>> referenced by crtbegin.c
>>>               /Users/kengoon/.buildozer/android/platform/android-ndk-r28c/toolchains/llvm/prebuilt/darwin-x86_64/bin/../sysroot/usr/lib/aarch64-linux-android/24/crtbegin_dynamic.o:(_start_main)
clang++: error: linker command failed with exit code 1 (use -v to see invocation)
 error: command '/opt/homebrew/bin/ccache' failed with exit code 1

but when I add " -shared" to LDFLAGS (this code below) it works fine:

# Taken from CythonRecipe
env['LDFLAGS'] = env['LDFLAGS'] + ' -L{} '.format(
self.ctx.get_libs_dir(arch.arch) +
' -L{} '.format(self.ctx.libs_dir) +
' -L{}'.format(join(self.ctx.bootstrap.build_dir, 'obj', 'local',
arch.arch)))

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)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions