-
Notifications
You must be signed in to change notification settings - Fork 18k
Windows - this app can't run on this PC #43529
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
Comments
The first thing to check is your anti-virus program. |
Thank you, but I disabled my antivirus program and still have the same issue. And note this only impacts Go programs using CGO on windows, other Go programs work correctly. |
Also tried with mingw 8.1.0-posix-sjli rev0 x64 and same error message. |
Could you please check the compilers and the program works with simple C code? |
Try |
Using the |
@LukeMauldin you see effect of buildmode change from https://golang.org/doc/go1.15#windows
You said that you use CGO to build your program. But you did not say what C code / library you used. You did not say what C compiler you used. You did not say what C compiler flags you used to build your program. Without this information it is impossible to answer your question. I won't be able to answer your question even if you provide this information, but I can say that your C setup works on Linux, but not on Windows. Building C programs is more complicated then Go.
See my previous answer. If you are not using CGO, then Go compiler has everything it needs to build your program regardless of buildmode setting. I hope it helps. Alex |
@ianlancetaylor could you add something to the docs about trying |
@networkimprov I think that's too vague. I would like to understand what the problem actually is first. |
Since Go adopted ASLR (-buildmode=pie) on Windows in 1.15, we've found that mode is incompatible with some DLLs (IIRC) and cgo scenarios like the above. Alex and I have resolved a number of bug reports here with "try -buildmode=exe". I don't see anything in the cmd/go or cmd/cgo docs about this. |
My first take on this is that we need to change back to defaulting to |
buildmode=pie was adopted for security reasons, see #35192 Maybe there's more to do to make it work all the time? cc @zx2c4 @gopherbot add OS-Windows |
@networkimprov what do you propose to say?
I don't see what we can say in docs. We don't even know what this issue problem is. How could we recommend solution without knowing what the problem is?
@ianlancetaylor I disagree. We all agreed that Go should generate ASLR by default. It does work for all pure Go programs, and most CGO programs. And we provided easy solution for people who cannot make their CGO programs build with ASLR. Alex |
What to say: If you have problems building or running a Windows cgo app, try |
We all agreed that Go programs should use ASLR by default. What you suggesting is that users disable ASLR even without understanding the implication of their action. I prefer they understand their problem before they start looking for solution. Alex |
As someone who has encountered this bug, I strongly think that something about it should be placed in the docs because it is a total show stopper until you know the buildmode work around. |
Apparently DLLs not linked appropriately may not work in ASLR programs, tho I would have thought you'd see an error which indicated that. EDIT: it could be due to 64-bit exe vs 32-bit dll, and/or a mingw bug. |
closing given the lack of recent reports. |
What version of Go are you using (
go version
)?C:\WINDOWS\system32>go version
go version go1.15.6 windows/amd64
Does this issue reproduce with the latest release?
Yes
What operating system and processor architecture are you using (
go env
)?What did you do?
Compiling a Go program that uses vendor Windows supplied libraries via CGO will not run. Gives a prompt "this app can't run on this PC". This same application works correctly on Linux. Ensured that the vendor Windows libraries are on the PATH and resolve correctly using dependency walker - https://www.dependencywalker.com/
Other Go applications that do not use CGO launch correctly. Verified that both the build system and running system are x64 systems.
Build command:
go build -v -o ./bin/XXX.exe -trimpath -ldflags="-X main.appVersion=v2.7.0"
Windows version: 2004 (Build 19041.630)
What did you expect to see?
The application to launch.
What did you see instead?
An error message from Windows stating "This app can't run on your PC". Looked in event logs but cannot find additional information. Tried running app via Administrator command prompt and same behavior.
The text was updated successfully, but these errors were encountered: