2

How do you compile and link a 64 bit Windows assembly program in Linux

I already know to run

nasm -f win64 generic_assembly.asm -o generic_output 

But after that I can't just run

ld generic_output -o generic_executable.exe 

and I have tried using GoLink.exe with wine but I am still skeptical as to whether it is actually working

Maybe I could use Mingw-w64 but I have no clue on how that would work

Any help would be appreciated I am mostly just looking for a linker that I can run from linux but otherwise a linker for Windows would also be appreciated.

2
  • 4
    You will need a windows cross compiler like MinGW. Your distro may already have a package with it pre-made (you just install it through your package manager). Once you have it installed you can run the LD from the cross compiler - it will likely be called x86_64-w64-mingw32-ld, the GCC cross compiler would be called x86_64-w64-mingw32-gcc etc. That is the naming convention on my Debian Jessie system. Commented Jun 21, 2016 at 6:58
  • 1
    Yup, I'd recommend just using x86_64-w64-mingw32-gcc to link .obj files from nasm into executables, in case there's anything non-obvious ld arg that's needed. (use -static and/or -nostdlib as appropriate). Commented Jun 21, 2016 at 9:50

1 Answer 1

2

To link the objects for 64 bit Windows from Linux install x86_64-w64-mingw32-gcc. To do this follow these steps:

  • Go to here and download the most recent build.
  • Unpack the archive to /opt/mingw64
  • Then do sudo ln -s /opt/mingw64/bin/x86_64-w64-mingw32-g++ /usr/bin/mingw64-g++

Now you have installed a cross compiler for Windows 64 bit, if you want the 32 bit version do the same but use this link.

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.