交叉编译在Windows 64(TDM-GCC-64)上转到.linux文件,但是尽管GOOS = linux,仍继续编译到.exe文件

I am attempting to compile a .go source file to a .linux file. I'm using TDM-GCC-64 on Windows 7 64-bit.

I have set my GOOS to 'linux'. I've also set GOARCH to amd64.

I then rebuild Go in C:\Go\src using make.bat. This all runs successfully.

The compilation runs successfully but each time it compiles a Windows .exe despite the system variables set.

My question is how to overcome this issue - what am I doing wrong?

Edit: I had MinGW installed before TDM-GCC, which did not work.

You can test to see if those values are exporting using echo like this:echo %GOOS%

If you modify the system variables without restarting your console it won't have the new values. You should try exporting via the command line using set GOOS="linux" and set GOARCH="amd64"

If this does not fix it I would follow the guide that Kluyg posted.