AllenDang / w32

A wrapper of windows apis for the Go Programming Language.
Other
761 stars 245 forks source link

w32.a(_all.o): malformed pe file: No error #40

Closed bbigras closed 10 years ago

bbigras commented 10 years ago

I only have the problem on 64-bits. It's fine on Xp 32-bits.

go version go1.3 windows/amd64 Windows 7 64-bits

Maybe it's a Golang bug.

package main

import (
    "fmt"
    "github.com/AllenDang/w32"
)

func main() {
    fmt.Println(w32.ANSI_CHARSET)
}
D:\Dev\go\Bogues\bugw32> go build
# _/D_/Dev/go/Bogues/bugw32
C:\Users\bbigras\AppData\Local\Temp\go-build866516527/github.com/AllenDang/w32.a(_all.o): malformed pe file: No error
biorhitm commented 10 years ago

You need rebuild w32.a In source w32 directory ...github.com\AllenDang\w32 type:

go build go install

bbigras commented 10 years ago

I still have the problem. Note that it's using w32.a from gopath\pkg instead of temp.

d:\>cd %GOPATH%\src\github.com\AllenDang\w32
d:\Dev\go\gopath\src\github.com\AllenDang\w32>go build
d:\Dev\go\gopath\src\github.com\AllenDang\w32>go install
d:\Dev\go\gopath\src\github.com\AllenDang\w32>
D:\Dev\go\Bogues\bugw32> go build
# _/D_/Dev/go/Bogues/bugw32
d:\dev\go\gopath\pkg\windows_amd64/github.com/AllenDang/w32.a(_all.o): malformed pe file: No error
D:\Dev\go\Bogues\bugw32>
biorhitm commented 10 years ago

Try delete w32.a and again build. Show output 'go env'

bbigras commented 10 years ago

I deleted w32.a and tried again without success.

D:\>cd %GOPATH%\src\github.com\AllenDang\w32
d:\Dev\go\gopath\src\github.com\AllenDang\w32>go build
d:\Dev\go\gopath\src\github.com\AllenDang\w32>go install

d:\Dev\go\gopath\src\github.com\AllenDang\w32>cd D:\Dev\go\Bogues\bugw32
D:\Dev\go\Bogues\bugw32>go build
# _/D_/Dev/go/Bogues/bugw32
d:\dev\go\gopath\pkg\windows_amd64/github.com/AllenDang/w32.a(_all.o): malformed pe file: No error
C:\Users\bbigras>go env
set GOARCH=amd64
set GOBIN=
set GOCHAR=6
set GOEXE=.exe
set GOHOSTARCH=amd64
set GOHOSTOS=windows
set GOOS=windows
set GOPATH=d:\dev\go\gopath
set GORACE=
set GOROOT=C:\Go
set GOTOOLDIR=C:\Go\pkg\tool\windows_amd64
set CC=gcc
set GOGCCFLAGS=-m64 -mthreads -fmessage-length=0
set CXX=g++
set CGO_ENABLED=1
biorhitm commented 10 years ago

My output 'go env' same as your except GOPATH. I have windows 7 64-bit too. Show output 'go build -x'

biorhitm commented 10 years ago

In source directory of w32 git show

commit 26c1073cd3bf2ac2752e5ccc5d9c2a4341d158ba Merge: a118f5e 8f5e4f1 Author: Allen Dang allengnr@gmail.com Date: Wed Jan 8 18:35:57 2014 -0800

Hash sum of w32.a are: MD5: 78097926da64befcb2d40a0cff1f84ad SHA1: "3b08eeaeb3ddf7d208f4000c83e72fdde5f07147"

bbigras commented 10 years ago

Show output 'go build -x'

D:\Dev\go\Bogues\bugw32>go build -x
WORK=C:\Users\bbigras\AppData\Local\Temp\go-build175372299
mkdir -p $WORK\_\D_\Dev\go\Bogues\bugw32\_obj\
cd D:\Dev\go\Bogues\bugw32
"C:\\Go\\pkg\\tool\\windows_amd64\\6g.exe" -o "C:\\Users\\bbigras\\AppData\\Local\\Temp\\go-build175372299\\_\\D_\\Dev\\go\\Bogues\\bugw32.a" -trimpath "C:\\Users\\bbigras\\AppData\\Local\\Temp\\go-build175372299" -p _/D_/Dev/go/Bogues/bugw32 -complete -D _/D_/Dev/go/Bogues/bugw32 -I "C:\\Users\\bbigras\\AppData\\Local\\Temp\\go-build175372299" -I "d:\\dev\\go\\gopath\\pkg\\windows_amd64" -pack "D:\\Dev\\go\\Bogues\\bugw32\\bugw32.go"
cd .
"C:\\Go\\pkg\\tool\\windows_amd64\\6l.exe" -o bugw32.exe -L "C:\\Users\\bbigras\\AppData\\Local\\Temp\\go-build175372299" -L "d:\\dev\\go\\gopath\\pkg\\windows_amd64" -extld=gcc "C:\\Users\\bbigras\\AppData\\Local\\Temp\\go-build175372299\\_\\D_\\Dev\\go\\Bogues\\bugw32.a"
# _/D_/Dev/go/Bogues/bugw32
d:\dev\go\gopath\pkg\windows_amd64/github.com/AllenDang/w32.a(_all.o): malformed pe file: No error

In source directory of w32 git show

D:\Dev\go\gopath\src\github.com\AllenDang\w32 [master...origin/master]> git show
commit 26c1073cd3bf2ac2752e5ccc5d9c2a4341d158ba
Merge: a118f5e 8f5e4f1
Author: Allen Dang <allengnr@gmail.com>
Date:   Wed Jan 8 18:35:57 2014 -0800

Hash sum of w32.a are: MD5: 78097926da64befcb2d40a0cff1f84ad SHA1: "3b08eeaeb3ddf7d208f4000c83e72fdde5f07147"

D:\Dev\go\gopath\pkg\windows_amd64\github.com\AllenDang>md5sum w32.a
a5dfbcef5195fe4452a1749aaee1f125 *w32.a

D:\Dev\go\gopath\pkg\windows_amd64\github.com\AllenDang>sha1sum w32.a
77563d7c3a780b7b381cd3e415447784c83546da *w32.a
biorhitm commented 10 years ago

You have another go :-). Try reinstall go. I have no idea. May be your w32.a for x86 arch? My w32.a start with:

__.PKGDEF       0           0     0     644     108696    `
go object windows amd64 go1.3 X:precisestack

$$
package w32
bbigras commented 10 years ago

My w32.a starts with:

!<arch>
__.PKGDEF       0           0     0     644     109200    `
go object windows amd64 go1.3 X:precisestack

$$
package w32

I'm using gcc version 4.7.1 (tdm64-1) but I'll try the Mingw-builds or Win-builds from http://mingw-w64.sourceforge.net/download.php.

bbigras commented 10 years ago

I don't have the problem anymore with the Win-builds gcc version.

gcc version 4.8.2 (GCC)

Sorry for the noise.