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

Can't set custom CGO_CFLAGS and CGO_LDFLAGS with "fyne package" on darwin #3276

Closed
2 tasks done
cra1nbow opened this issue Sep 22, 2022 · 4 comments
Closed
2 tasks done
Labels
bug Something isn't working Hacktoberfest

Comments

@cra1nbow
Copy link

Checklist

  • I have searched the issue tracker for open issues that relate to the same problem, before opening a new one.
  • This issue only relates to a single bug. I will open new issues for any other problems.

Describe the bug

in Darwin, can't custom CGO_CFLAGS and CGO_LDFLAGS

go run and go build works well

How to reproduce

  1. clone https://github.com/zergon321/reisen
  2. install ffmpeg brew install ffmpeg --build-from-source
  3. CGO_CFLAGS="-I/opt/homebrew/Cellar/ffmpeg/5.1.1/include" CGO_LDFLAGS="-L/opt/homebrew/Cellar/ffmpeg/5.1.1/lib/" go run examples/player/main.go working well
  4. CGO_CFLAGS="-I/opt/homebrew/Cellar/ffmpeg/5.1.1/include" CGO_LDFLAGS="-L/opt/homebrew/Cellar/ffmpeg/5.1.1/lib/" fyne package doesn't work (because fyne overwrite CGO_CFLAGS and CGO_LDFLAGS)

Screenshots

No response

Example code

https://github.com/zergon321/reisen

Fyne version

2.2.3

Go compiler version

1.19

Operating system

macOS

Operating system version

MacOSX Ventura 13.0

Additional Information

env = append(env, "CGO_CFLAGS=-mmacosx-version-min=10.11", "CGO_LDFLAGS=-mmacosx-version-min=10.11")

@cra1nbow cra1nbow added the unverified A bug that has been reported but not verified label Sep 22, 2022
@Aklscc
Copy link

Aklscc commented Sep 27, 2022

Hi, I use an CGO_LDFLAGS on windows in Makefile:

build:
	CGO_LDFLAGS="-H=windowsgui" \
	go build -x -o $(EXE) .

And then, I got an error:
gcc.exe: error: unrecognized command line option '-H=windowsgui'; did you mean ' -mwindows'?

But If I put it in go build, run successfully.
go build -ldflags -H=windowsgui -o main.exe .

What's the difference between them?
@cra1nbow

@cra1nbow
Copy link
Author

Hi, I use an CGO_LDFLAGS on windows in Makefile:

build:
	CGO_LDFLAGS="-H=windowsgui" \
	go build -x -o $(EXE) .

And then, I got an error: gcc.exe: error: unrecognized command line option '-H=windowsgui'; did you mean ' -mwindows'?

But If I put it in go build, run successfully. go build -ldflags -H=windowsgui -o main.exe .

What's the difference between them? @cra1nbow

I think ldflags in go build is option for golang, not CGO
CGO_LDFLAGS is injected in gcc command, -ldflags is injected in go build command

hiding windows is controlled by golang compiler, so if you want to hide gui, use -ldflags

build: go build -ldflags -H=widnowsgui -x -o $(EXE) .

@andydotxyz
Copy link
Member

Also the windows hiding issue is completely handled by fyne package so you don't have to learn the details https://developer.fyne.io/started/packaging

@andydotxyz andydotxyz changed the title can't custom CGO_CFLAGS and CGO_LDFLAGS in darwin can't custom CGO_CFLAGS and CGO_LDFLAGS with "fyne package" on darwin Sep 27, 2022
@andydotxyz andydotxyz added bug Something isn't working and removed unverified A bug that has been reported but not verified labels Sep 27, 2022
@Jacalz Jacalz changed the title can't custom CGO_CFLAGS and CGO_LDFLAGS with "fyne package" on darwin Can't set custom CGO_CFLAGS and CGO_LDFLAGS with "fyne package" on darwin Sep 30, 2022
@andydotxyz
Copy link
Member

Fixed on develop ready for next release, thanks @PucklaMotzer09

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

No branches or pull requests

3 participants