Skip to content

Fails to build android library #113

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
mgasiorowski opened this issue Jan 19, 2021 · 7 comments
Closed

Fails to build android library #113

mgasiorowski opened this issue Jan 19, 2021 · 7 comments

Comments

@mgasiorowski
Copy link

Hi.

I followed instructions for building libraries for mobile (https://github.com/ProtonMail/gopenpgp#using-with-go-mobile), and ios/macos builds without a problem.

But android fails with error:

# runtime/cgo
ld: error: duplicate symbol: x_cgo_inittls
>>> defined at gcc_android.c:90
>>>            $WORK/b108/_x003.o:(x_cgo_inittls)
>>> defined at gcc_linux_arm.c:13
>>>            $WORK/b108/_x006.o:(.bss+0x4)
clang: error: linker command failed with exit code 1 (use -v to see invocation)

go version go version go1.15.6 darwin/amd64

All environment variables set.

I tried with NDK versions:

  • 21.0.6113669
  • 22.0.7026061
@marinthiercelin
Copy link
Contributor

marinthiercelin commented Jan 20, 2021

Hey, it seems like it's more an issue about golang.org/x/mobile than with gopenpgp.

It could be related to this issue golang/go#42655.

In the meantime, I managed to make it work for NDK version 21.3.6528147 could you try it on your side ?

@marinthiercelin
Copy link
Contributor

We also have prepared builds on github if you need https://github.com/ProtonMail/gopenpgp/actions?query=workflow%3A%22Gomobile+for+Android%22

@mgasiorowski
Copy link
Author

With 21.3.6528147 I don't see any errors, but the android directory is still empty.

@marinthiercelin
Copy link
Contributor

In my case I see the build inside the dist/android folder.
Could you share an execution trace of the script ?

@mgasiorowski
Copy link
Author

Here you go, log for android build
https://gist.github.com/mgasiorowski/aa16875c0404a441057905243381803a

Directory tree after build:

.
├── Gopenpgp.xcframework
│   ├── Info.plist
│   ├── ios-arm64
│   ├── ios-x86_64-maccatalyst
│   ├── ios-x86_64-simulator
│   └── macos-x86_64
├── android
├── ios
│   └── Gopenpgp.framework
├── ios-simulator
│   └── Gopenpgp.framework
├── macos
│   └── Gopenpgp.framework
└── macos-ui
    └── Gopenpgp.framework

@marinthiercelin
Copy link
Contributor

marinthiercelin commented Jan 25, 2021

Thanks for the log.
I can still see the same error you had before (line 706).

# runtime/cgo
ld: error: duplicate symbol: x_cgo_inittls
>>> defined at gcc_android.c:90
>>>            $WORK/b108/_x003.o:(x_cgo_inittls)
>>> defined at gcc_linux_arm.c:13
>>>            $WORK/b108/_x006.o:(.bss+0x4)
clang: error: linker command failed with exit code 1 (use -v to see invocation)

According to golang/go#42655, an additional issue is that in gomobile $ANDROID_HOME/ndk-bundle will have precedence over the $ANDROID_NDK_HOME so even if you set $ANDROID_NDK_HOME is set to a version that works, it will be ignored by gomobile (see here).
Can you try to temporarily rename the $ANDROID_HOME/ndk-bundle folder to something else, and set $ANDROID_NDK_HOME to your installed version of 21.3.6528147 and then try to rebuild ?

@mgasiorowski
Copy link
Author

After swapping the ndk-bundle directory to version 21.3.6528147 (cp -r ndk/21.3.6528147 ndk-bundle), the library built correctly. Thanks for your help :)

@wussler wussler closed this as completed Mar 8, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants