Unable to run get .exe file from assembly NASM

24 views Asked by At

Recently I'm trying to learn Assembly but I got stuck from creating an EXE file from it. It keeps making errors although I've try to research about it a lot.

I've read a lot of tutorial on the Internet about "How to run a assembly files", "How to compile Assembly with NASM", "Using gcc to run Assembly files",... and I'm currently using MinGW from CodeBlocks and NASM trying to complile it. I've successed to create one .obj file by the nasm -f hello.asm command. But then I got stuck with the next one, I used the command gcc hello.obj -o hello.exe trying to create an .exe file. And I got this error:

C:/Program Files/CodeBlocks/MinGW/bin/../lib/gcc/x86_64-w64-mingw32/8.1.0/../../../../x86_64-w64-mingw32/bin/ld.exe: i386 architecture of input file `hello.obj' is incompatible with i386:x86-64 output hello.obj:hello.asm:(.text+0x6): undefined reference to `_printf' C:/Program Files/CodeBlocks/MinGW/bin/../lib/gcc/x86_64-w64-mingw32/8.1.0/../../../../x86_64-w64-mingw32/lib/../lib/libmingw32.a(lib64_libmingw32_a-crt0_c.o):crt0_c.c:(.text.startup+0x2e): undefined reference to `WinMain' collect2.exe: error: ld returned 1 exit status   

I researched some more on the Internet but I was unable to find anyone who have the same question as me. I am also sure that there is nothing wrong with the %PATH% system varibles. And I am also sure that there is no errors in my file (it is from this tutorial site in case you need it).

Thank you!

0

There are 0 answers