Skip to content
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

Duplicate symbol error when compiling for Android with NDK 23 #2064

Closed
mythril opened this issue Mar 4, 2021 · 8 comments
Closed

Duplicate symbol error when compiling for Android with NDK 23 #2064

mythril opened this issue Mar 4, 2021 · 8 comments
Labels
bug Something isn't working

Comments

@mythril
Copy link

mythril commented Mar 4, 2021

Describe the bug:

Attempting to compile the fyne_demo (or my own fyne app) for android errors out with a duplicate symbol message.

To Reproduce:

in the fyne_demo repo / subdir
run:

$ ANDROID_NDK_HOME=~/Android/Sdk/ndk/23.0.7123448/ fyne package -os android -appID com.example.myapp -icon ./data/fyne_scene_light.png 

see error:

go build -buildmode=c-shared -o /tmp/gomobile-work-971507893/lib/armeabi-v7a/libfyne_demo.so fyne.io/fyne/v2/cmd/fyne_demo failed: exit status 2
# github.com/fyne-io/mobile/app
ld: error: duplicate symbol: display
>>> defined at android.go:38
>>>            $WORK/b175/_x001.o:(display)
>>> defined at android.go:38 (/home/###/go/pkg/mod/github.com/fyne-io/mobile@v0.1.2/app/android.go:38)
>>>            $WORK/b175/_x002.o:(.bss+0x0)

ld: error: duplicate symbol: surface
>>> defined at android.go:39
>>>            $WORK/b175/_x001.o:(surface)
>>> defined at android.go:39 (/home/###/go/pkg/mod/github.com/fyne-io/mobile@v0.1.2/app/android.go:39)
>>>            $WORK/b175/_x002.o:(.bss+0x4)

ld: error: duplicate symbol: display
>>> defined at android.go:38
>>>            $WORK/b175/_x001.o:(display)
>>> defined at android.c:146
>>>            $WORK/b175/_x004.o:(.bss+0x18)

ld: error: duplicate symbol: surface
>>> defined at android.go:39
>>>            $WORK/b175/_x001.o:(surface)
>>> defined at android.c:147
>>>            $WORK/b175/_x004.o:(.bss+0x1C)
clang: error: linker command failed with exit code 1 (use -v to see invocation)

Device (please complete the following information):

OS:

$ cat /etc/*-release
DISTRIB_ID=Ubuntu
DISTRIB_RELEASE=20.04
DISTRIB_CODENAME=focal
DISTRIB_DESCRIPTION="Ubuntu 20.04.2 LTS"
NAME="Ubuntu"
VERSION="20.04.2 LTS (Focal Fossa)"
ID=ubuntu
ID_LIKE=debian
PRETTY_NAME="Ubuntu 20.04.2 LTS"
VERSION_ID="20.04"
HOME_URL="https://www.ubuntu.com/"
SUPPORT_URL="https://help.ubuntu.com/"
BUG_REPORT_URL="https://bugs.launchpad.net/ubuntu/"
PRIVACY_POLICY_URL="https://www.ubuntu.com/legal/terms-and-policies/privacy-policy"
VERSION_CODENAME=focal
UBUNTU_CODENAME=focal

Go version:

$ go version
go version go1.16 linux/amd64

Fyne version:

~ c29a062

@mythril mythril added the bug Something isn't working label Mar 4, 2021
@fpabl0
Copy link
Member

fpabl0 commented Mar 6, 2021

Hello @mythril, it seems that this is related to #1912 (if not the same) and golang/go#44121. As a workaround, could you please try downgrading your NDK version to v21.x.x? That should solve the issue :)

andydotxyz added a commit that referenced this issue Mar 8, 2021
@andydotxyz
Copy link
Member

This should be fixed after merging a fix to our gomobile fork.
Can you please test develop branch?

@mythril
Copy link
Author

mythril commented Mar 9, 2021

@andydotxyz Seems to fail with a different issue but it doesn't directly complain about fyne code afaict:

$ ANDROID_NDK_HOME=~/Android/Sdk/ndk/23.0.7123448/ fyne package -os android -appID com.example.myapp -icon ./../fyne_settings/Icon.png 
/home/###/Android/Sdk/ndk/23.0.7123448/toolchains/llvm/prebuilt/linux-x86_64/bin/arm-linux-androideabi-nm /tmp/gomobile-work-124400139/lib/armeabi-v7a/libfyne_demo.so: fork/exec /home/###/Android/Sdk/ndk/23.0.7123448/toolchains/llvm/prebuilt/linux-x86_64/bin/arm-linux-androideabi-nm: no such file or directory

@andydotxyz
Copy link
Member

Yes that looks like your install may not be very happy - perhaps try updating / reinstalling NDK and/or resetting your Go cache

@equisde
Copy link

equisde commented Aug 16, 2021

@andydotxyz Seems to fail with a different issue but it doesn't directly complain about fyne code afaict:

$ ANDROID_NDK_HOME=~/Android/Sdk/ndk/23.0.7123448/ fyne package -os android -appID com.example.myapp -icon ./../fyne_settings/Icon.png 
/home/###/Android/Sdk/ndk/23.0.7123448/toolchains/llvm/prebuilt/linux-x86_64/bin/arm-linux-androideabi-nm /tmp/gomobile-work-124400139/lib/armeabi-v7a/libfyne_demo.so: fork/exec /home/###/Android/Sdk/ndk/23.0.7123448/toolchains/llvm/prebuilt/linux-x86_64/bin/arm-linux-androideabi-nm: no such file or directory

i'm getting this same issue tried downloading ndk and setting it on system variables and also i tried installing through android studio but i'm getting the no such file or directory error what should i do?

edit: i'm on windows
edit 2: i got it working downgrading ndk to version 21.4.7075529

@andydotxyz
Copy link
Member

To get the fix you'll need to use the unreleased (develop) version of Fyne, the fix rolls out in v2.1 next month.

@andydotxyz
Copy link
Member

@andydotxyz Seems to fail with a different issue but it doesn't directly complain about fyne code afaict:

$ ANDROID_NDK_HOME=~/Android/Sdk/ndk/23.0.7123448/ fyne package -os android -appID com.example.myapp -icon ./../fyne_settings/Icon.png 
/home/###/Android/Sdk/ndk/23.0.7123448/toolchains/llvm/prebuilt/linux-x86_64/bin/arm-linux-androideabi-nm /tmp/gomobile-work-124400139/lib/armeabi-v7a/libfyne_demo.so: fork/exec /home/###/Android/Sdk/ndk/23.0.7123448/toolchains/llvm/prebuilt/linux-x86_64/bin/arm-linux-androideabi-nm: no such file or directory

i'm getting this same issue tried downloading ndk and setting it on system variables and also i tried installing through android studio but i'm getting the no such file or directory error what should i do?

edit: i'm on windows
edit 2: i got it working downgrading ndk to version 21.4.7075529

Apologies this got dropped... We need to support the latest build tools, so I opened #2498 to track it.

@andydotxyz
Copy link
Member

For anyone that isn't able to remove the gomobile dependency from your project (usually due to transitive dependencies) there is another solution!

Fyne has a gomobile-bridge project that maps the gomobile APIs into a Fyne runtime: https://github.com/fyne-io/gomobile-bridge

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

4 participants