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
cmd/cgo: msvc created dll can be linked with cgo but executable fails with "The procedure entry point AddVectoredExceptionHandler could not be located" #43244
Comments
The error occurs when both sample.dll and sample.lib during build time are placed in the directory used as library path (-L). This seems to cause an invalid import section in the generated PE file.
As one can see, the symbols of kernel32 appear twice, and falsely in the import section of the sample.dll |
Note that 1.13 is no longer supported. @gopherbot add OS-Windows |
@philippseith Can you reproduce this issue in a supported version of Go? Either 1.14 or 1.15? |
I reproduced it with |
@gopherbot remove WaitingForInfo |
Note that I ran into this issue as well, and have some addiitonal notes. First, I do not see the issue with binutils 2.36.1. I can link against a DLL import library and the resulting binary has proper imports. I do see this issue cross compiling on an Ubuntu 20.04 system with MinGW binutils 2.34 when linking against a DLL import library. Basically, if I have a third party library MyLibrary.DLL with an import library MyLibrary.LIB, then, if I link with However, ld on cygwin/mingw allows you to link directly against the DLL (for reference, see this link). If I replace the MyLibrary.LIB file in the library search path with MyLibrary.DLL, then linking with This may not be a Go issue, since I have tried this on Go 1.13, Go 1.15, and now Go 1.19, with the same results. For reference, here is a snippet from dumpbin when I link against an import library (mingw ld 2.34):
Notice all KERNEL32.DLL symbols like And this is what it looks like when I link directly against the DLL (mingw ld 2.34):
Here is the equivalent dump when linked with the importlib on mingw ld 2.36.1:
|
What version of Go are you using (
go version
)?Does this issue reproduce with the latest release?
Yes
What operating system and processor architecture are you using (
go env
)?go env
OutputWhat did you do?
GOARCH=amd64 GOOS=windows CGO_ENABLED=1 CC=x86_64-w64-mingw32-gcc go build -o cgotest.exe main.go
with this trival main.goWhat did you expect to see?
Hello World
What did you see instead?
A messagebox containing this text:
The text was updated successfully, but these errors were encountered: