0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

「[Windows] そのexeがx64かx86かを見分ける方法 Part2」をmacOSのGoで確認

Last updated at Posted at 2020-11-07

何気に遥佐保さんのブログ記事「[Windows] そのexeがx64かx86かを見分ける方法 Part2」をGoで確認してみました。

Goはクロスコンパイルができますからね。ブログ記事投稿のツイートから20分ほどで確認できました。

1.x64(amd64)用とx32(386)用のGoのソースコードを書く。(違いは出力メッセージのみ)

$ cat main64.go 
package main

import (
	"fmt"
)

func main() {
	fmt.Println("GOOS=windows GOARCH=amd64")
}
$ cat main32.go 
package main

import (
	"fmt"
)

func main() {
	fmt.Println("GOOS=windows GOARCH=386")
}

2.macOS上でGoのソースコードをx64(amd64)とx32(386)でコンパイル。

$ GOOS=windows GOARCH=amd64 go build -o main64.exe main64.go 
$ GOOS=windows GOARCH=386 go build -o main32.exe main32.go

3.ファイルの生成を確認。

$ ls main*
main32.exe main32.go  main64.exe main64.go

4.fileコマンドで確認。

$ file main32.exe 
main32.exe: PE32 executable (console) Intel 80386 (stripped to external PDB), for MS Windows
$ file main64.exe
main64.exe: PE32+ executable (console) x86-64 (stripped to external PDB), for MS Windows

やったね!q@w@p

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?