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

fyne.io MenuItem type conflicting with systray MenuItem type #632

Closed
davetbo opened this issue Jan 27, 2020 · 6 comments
Closed

fyne.io MenuItem type conflicting with systray MenuItem type #632

davetbo opened this issue Jan 27, 2020 · 6 comments
Labels
bug Something isn't working

Comments

@davetbo
Copy link

davetbo commented Jan 27, 2020

Hello,

I'm trying to build my first Go app using Fyne for a gui toolkit and systray to create a system tray icon and menu.

When I try to compile I'm getting this error:

duplicate symbol _OBJC_CLASS_$_MenuItem in:
    /var/folders/w2/dy449vjn1qq1hrn5bjg8ctd80000gn/T/go-link-663211736/000004.o
    /var/folders/w2/dy449vjn1qq1hrn5bjg8ctd80000gn/T/go-link-663211736/000018.o
duplicate symbol _OBJC_METACLASS_$_MenuItem in:
    /var/folders/w2/dy449vjn1qq1hrn5bjg8ctd80000gn/T/go-link-663211736/000004.o
    /var/folders/w2/dy449vjn1qq1hrn5bjg8ctd80000gn/T/go-link-663211736/000018.o
ld: 2 duplicate symbols for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)

I'm 99% sure it's because both Fyne and Systray (github.com/getlantern/systray) create a new type called MenuItem.

Being new to Go , I'm not sure how to resolve this conflict. I'm using go version go1.13.6 darwin/amd64. I do have plenty of other programming experience in PHP, Javascript, and Python, so I'm not a total noob, but Go is a bit different with respect to its implementation of "object orientedness" (or lack thereof).

I appreciate your advice :)

Thanks!
Dave

@davetbo
Copy link
Author

davetbo commented Jan 27, 2020

Confirmed that this is the issue. If I go through systray and change all references to their MenuItem to SMenuItem it works. Obviously modifying someone else's library is not optimal for applying future updates.

There must be a way to use multiple libraries with overlapping variable names without crashing the compiler. Are the different package names not designed to prevent this conflict?

@andydotxyz
Copy link
Member

You're quite right about the issue but slightly mistaken about the cause.
Yes, Go packages stop this from happening. The error that you see is in underlying Objective-C code.
If you change the fyne code in internal/driver/glfw/menu_darwin.m to prefix MenuItem with Fyne or somesuch text then the problem should be resolved.

Objective-C does not have the same namespace system and so manual namespacing is required - and we missed it. The function names should probably be prefixed if they are not part of the declared type.

@andydotxyz andydotxyz added the bug Something isn't working label Jan 27, 2020
@davetbo
Copy link
Author

davetbo commented Jan 27, 2020 via email

@andydotxyz
Copy link
Member

When it was fixed at your end did the app work? As I understand it both projects require the main loop grabbed...

@davetbo
Copy link
Author

davetbo commented Jan 27, 2020 via email

@andydotxyz
Copy link
Member

OK, the rename is going to be in 1.2.2 later this week

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

2 participants