golang-design / clipboard

📋 cross-platform clipboard package that supports accessing text and image in Go (macOS/Linux/Windows/Android/iOS)
https://golang.design/x/clipboard
MIT License
630 stars 68 forks source link

ld: error: duplicate symbol: when using with Fyne Android #28

Closed ntsd closed 2 years ago

ntsd commented 2 years ago

I tried to remove the clipboard it's working fine.

logs

$ fyne-cross android
[i] Target: android/multiple
[i] Cleaning target directories...
[✓] "dist" dir cleaned: C:\Users\ntsd\Desktop\git\ntsd\cross-clipboard\fyne-cross\dist\android
[✓] "temp" dir cleaned: C:\Users\ntsd\Desktop\git\ntsd\cross-clipboard\fyne-cross\tmp\android
[✓] "bin" dir cleaned: C:\Users\ntsd\Desktop\git\ntsd\cross-clipboard\fyne-cross\bin\android
[i] Checking for go.mod: C:\Users\ntsd\Desktop\git\ntsd\cross-clipboard\go.mod
[✓] go.mod found
[i] Packaging app...
go build -buildmode=c-shared -o /tmp/gomobile-work-1926614866/lib/armeabi-v7a/libcross-clipboard.so github.com/ntsd/cross-clipboard failed: exit status 2
# fyne.io/fyne/v2/internal/driver/mobile
android.c:50:9: warning: returning 'const char *' from a function with result type 'char *' discards qualifiers [-Wincompatible-pointer-types-discards-qualifiers]
android.c:67:48: warning: incompatible integer to pointer conversion passing 'uintptr_t' (aka 'unsigned int') to parameter of type 'jobject' (aka 'void *') [-Wint-conversion]     
android.c:71:55: warning: incompatible integer to pointer conversion passing 'uintptr_t' (aka 'unsigned int') to parameter of type 'jobject' (aka 'void *') [-Wint-conversion]     
android.c:122:48: warning: incompatible integer to pointer conversion passing 'uintptr_t' (aka 'unsigned int') to parameter of type 'jobject' (aka 'void *') [-Wint-conversion]    
android.c:125:48: warning: incompatible integer to pointer conversion passing 'uintptr_t' (aka 'unsigned int') to parameter of type 'jobject' (aka 'void *') [-Wint-conversion]    
android.c:181:50: warning: passing 'char *' to parameter of type 'jbyte *' (aka 'signed char *') converts between pointers to integer types with different sign [-Wpointer-sign]   
android.c:191:48: warning: passing 'char *' to parameter of type 'const jbyte *' (aka 'const signed char *') converts between pointers to integer types with different sign [-Wpointer-sign]
# fyne.io/fyne/v2/app
app_mobile_and.c:46:48: warning: incompatible integer to pointer conversion passing 'uintptr_t' (aka 'unsigned int') to parameter of type 'jobject' (aka 'void *') [-Wint-conversion]
app_mobile_and.c:49:48: warning: incompatible integer to pointer conversion passing 'uintptr_t' (aka 'unsigned int') to parameter of type 'jobject' (aka 'void *') [-Wint-conversion]
app_mobile_and.c:85:30: warning: incompatible integer to pointer conversion passing 'uintptr_t' (aka 'unsigned int') to parameter of type 'jobject' (aka 'void *') [-Wint-conversion]
app_mobile_and.c:98:33: warning: incompatible pointer to integer conversion passing 'JNIEnv *' (aka 'const struct JNINativeInterface **') to parameter of type 'uintptr_t' (aka 'unsigned int') [-Wint-conversion]
app_mobile_and.c:42:36: note: passing argument to parameter 'jni_env' here
# github.com/ntsd/cross-clipboard
/usr/local/go/pkg/tool/linux_amd64/link: running /usr/local/android_sdk/ndk-bundle/toolchains/llvm/prebuilt/linux-x86_64/bin/armv7a-linux-androideabi16-clang failed: exit status 1
ld: error: duplicate symbol: callMain
>>> defined at _cgo_export.c:44
>>>            /tmp/go-link-655786190/000020.o:(callMain)
>>> defined at _cgo_export.c:44
>>>            /tmp/go-link-655786190/000039.o:(.text+0x50)

ld: error: duplicate symbol: onConfigurationChanged
>>> defined at _cgo_export.c:334
>>>            /tmp/go-link-655786190/000020.o:(onConfigurationChanged)
>>> defined at _cgo_export.c:317
>>>            /tmp/go-link-655786190/000039.o:(.text+0x4D4)

ld: error: duplicate symbol: onContentRectChanged
>>> defined at _cgo_export.c:298
>>>            /tmp/go-link-655786190/000020.o:(onContentRectChanged)
>>> defined at _cgo_export.c:298
>>>            /tmp/go-link-655786190/000039.o:(.text+0x484)

ld: error: duplicate symbol: onCreate
>>> defined at _cgo_export.c:150
>>>            /tmp/go-link-655786190/000020.o:(onCreate)
>>> defined at _cgo_export.c:150
>>>            /tmp/go-link-655786190/000039.o:(.text+0x214)

ld: error: duplicate symbol: onDestroy
>>> defined at _cgo_export.c:167
>>>            /tmp/go-link-655786190/000020.o:(onDestroy)
>>> defined at _cgo_export.c:167
>>>            /tmp/go-link-655786190/000039.o:(.text+0x25C)

ld: error: duplicate symbol: onInputQueueCreated
>>> defined at _cgo_export.c:260
>>>            /tmp/go-link-655786190/000020.o:(onInputQueueCreated)
>>> defined at _cgo_export.c:260
>>>            /tmp/go-link-655786190/000039.o:(.text+0x3E4)

ld: error: duplicate symbol: onInputQueueDestroyed
>>> defined at _cgo_export.c:279
>>>            /tmp/go-link-655786190/000020.o:(onInputQueueDestroyed)
>>> defined at _cgo_export.c:279
>>>            /tmp/go-link-655786190/000039.o:(.text+0x434)

ld: error: duplicate symbol: onLowMemory
>>> defined at _cgo_export.c:351
>>>            /tmp/go-link-655786190/000020.o:(onLowMemory)
>>> defined at _cgo_export.c:334
>>>            /tmp/go-link-655786190/000039.o:(.text+0x51C)

ld: error: duplicate symbol: onNativeWindowCreated
>>> defined at _cgo_export.c:203
>>>            /tmp/go-link-655786190/000020.o:(onNativeWindowCreated)
>>> defined at _cgo_export.c:203
>>>            /tmp/go-link-655786190/000039.o:(.text+0x2F4)

ld: error: duplicate symbol: onNativeWindowDestroyed
>>> defined at _cgo_export.c:241
>>>            /tmp/go-link-655786190/000020.o:(onNativeWindowDestroyed)
>>> defined at _cgo_export.c:241
>>>            /tmp/go-link-655786190/000039.o:(.text+0x394)

ld: error: duplicate symbol: onNativeWindowRedrawNeeded
>>> defined at _cgo_export.c:222
>>>            /tmp/go-link-655786190/000020.o:(onNativeWindowRedrawNeeded)
>>> defined at _cgo_export.c:222
>>>            /tmp/go-link-655786190/000039.o:(.text+0x344)

ld: error: duplicate symbol: onPause
>>> defined at _cgo_export.c:116
>>>            /tmp/go-link-655786190/000020.o:(onPause)
>>> defined at _cgo_export.c:116
>>>            /tmp/go-link-655786190/000039.o:(.text+0x184)

ld: error: duplicate symbol: onResume
>>> defined at _cgo_export.c:78
>>>            /tmp/go-link-655786190/000020.o:(onResume)
>>> defined at _cgo_export.c:78
>>>            /tmp/go-link-655786190/000039.o:(.text+0xE0)

ld: error: duplicate symbol: onSaveInstanceState
>>> defined at _cgo_export.c:95
>>>            /tmp/go-link-655786190/000020.o:(onSaveInstanceState)
>>> defined at _cgo_export.c:95
>>>            /tmp/go-link-655786190/000039.o:(.text+0x128)

ld: error: duplicate symbol: onStart
>>> defined at _cgo_export.c:61
>>>            /tmp/go-link-655786190/000020.o:(onStart)
>>> defined at _cgo_export.c:61
>>>            /tmp/go-link-655786190/000039.o:(.text+0x98)

ld: error: duplicate symbol: onStop
>>> defined at _cgo_export.c:133
>>>            /tmp/go-link-655786190/000020.o:(onStop)
>>> defined at _cgo_export.c:133
>>>            /tmp/go-link-655786190/000039.o:(.text+0x1CC)

ld: error: duplicate symbol: onWindowFocusChanged
>>> defined at _cgo_export.c:184
>>>            /tmp/go-link-655786190/000020.o:(onWindowFocusChanged)
>>> defined at _cgo_export.c:184
>>>            /tmp/go-link-655786190/000039.o:(.text+0x2A4)

ld: error: duplicate symbol: setCurrentContext
>>> defined at _cgo_export.c:25
>>>            /tmp/go-link-655786190/000020.o:(setCurrentContext)
>>> defined at _cgo_export.c:25
>>>            /tmp/go-link-655786190/000039.o:(.text+0x0)

ld: error: duplicate symbol: ANativeActivity_onCreate
>>> defined at android.c:76
>>>            /tmp/go-link-655786190/000023.o:(ANativeActivity_onCreate)
>>> defined at android.c:72
>>>            /tmp/go-link-655786190/000041.o:(.text+0x40)

ld: error: duplicate symbol: JNI_OnLoad
>>> defined at android.c:57
>>>            /tmp/go-link-655786190/000023.o:(JNI_OnLoad)
>>> defined at android.c:53
>>>            /tmp/go-link-655786190/000041.o:(.text+0x0)

ld: error: too many errors emitted, stopping now (use -error-limit=0 to see all errors)
clang: error: linker command failed with exit code 1 (use -v to see invocation)

[✗] could not package the Fyne app: could not package the Fyne app: exit status 1

Go version: 1.18 Clipboard version: 0.6.2 Fyne version: 2.1.4 NDK version: 21.4.7075529, 23.1.7779620

changkun commented 2 years ago

I don't think the package can be compatible with Fyne, or at least I couldn't find a way to be compatible with any other GUI frameworks (such as Gio). The reason is to be able to work with Android, it requires code to run on JVM, and this is a separate environment in Fyne compared to this package, which we use gomobile.

As far as I understood, this package implements the same clipboard functionality (copying text) as Fyne. If you only need Android/iOS support, Fyne's API set is probably enough for your use case: https://developer.fyne.io/api/v2.1/clipboard.html

ntsd commented 2 years ago

Thank you, I just tested with gomobile it works, I think I will use another OpenGL framework.