dontpanic92 / wxGo

Golang wxWidgets Wrapper
Other
404 stars 51 forks source link

Invalid flag in #cgo #44

Closed axelniedenhoff closed 6 years ago

axelniedenhoff commented 6 years ago

I was just updating my wxGo by doing

go get -u -v github.com/dontpanic92/wxGo/wx

Then I got this:

github.com/dontpanic92/wxGo (download) github.com/dontpanic92/wxGo/wx go build github.com/dontpanic92/wxGo/wx: invalid flag in #cgo LDFLAGS: -s

I have Go version 1.9.4 on Ubuntu Linux 17.10.

Any idea?

guilhas commented 6 years ago

Hello,

Same.

OS: Win 7 x64

Golang 1.9.3 OK :+1:

Golang 1.9.4 NOK

C:/tools/go/bin/go.exe build -i [C:/Users/Gugas/.wks_go/src/wxTest1] go build github.com/dontpanic92/wxGo/wx: invalid flag in #cgo CXXFLAGS: -fpermissive Error: process exited with code 1.

Golang 1.10.0 NOK

C:/tools/go/bin/go.exe build -i [C:/Users/Gugas/.wks_go/src/wxTest1] go build github.com/dontpanic92/wxGo/wx: invalid flag in #cgo LDFLAGS: -Wl,--subsystem,windows Error: process exited with code 1.

Regards

axelniedenhoff commented 6 years ago

It seems this is the expected behavior after a security vulnerability in Go was fixed. See this article for background and a workaround: https://github.com/golang/go/wiki/InvalidFlag So, in my case, this works: CGO_LDFLAGS_ALLOW=-s go get -u -v github.com/dontpanic92/wxGo/wx

ernstvanzyl commented 6 years ago

As has been suggested elsewhere, try this quick and dirty "fix";

export CGO_CXXFLAGS_ALLOW=".*" 
export CGO_LDFLAGS_ALLOW=".*" 
export CGO_CFLAGS_ALLOW=".*"
alanbaumgartner commented 6 years ago

@guilhas did you find a fix for golang 1.10.0 issue?

dontpanic92 commented 6 years ago

Hi all, a little update about this issue:

I think the workaround way suggested by @ernstvanzyl should work, but I haven't test it.

alanbaumgartner commented 6 years ago

@dontpanic92 I am fairly new to Go and don't understand completely how to do what he suggested. I am using windows so I think I have to use "set" instead of "export" but after doing these three commands set CGO_CXXFLAGS_ALLOW=".*" set CGO_LDFLAGS_ALLOW=".*" set CGO_CFLAGS_ALLOW=".*"

and running go get github.com/dontpanic92/wxGo/wx I still have the same error. What am I doing wrong?

dontpanic92 commented 6 years ago

@alanbaumgartner don't include the " on Windows, i.e. set CGO_LDFLAGS_ALLOW=.*

guilhas commented 6 years ago

I just downgraded Go

jkvatne commented 6 years ago

@dontpanic92, could you please add a note in the README.md file. It took me a long time to find this issue that solves the installation problem with GO 1.10. Also a more exact content of the flags instead of the "catch all" would be fine.

k-takata commented 6 years ago

Also a more exact content of the flags instead of the "catch all" would be fine.

On Windows, I use this:

set "CGO_LDFLAGS_ALLOW=-Wl,--subsystem,windows|-mwindows"

(Using GCC 7.3.0 on MSYS2, which doesn't require -Wl,--allow-multiple-definitions.)

axelniedenhoff commented 6 years ago

From my point of view, this issue has been fixed for go 1.10.1. For use cases that still show the problem, workarounds have been documented, so I am closing the issue.