I'm trying to build hello.asm into a Windows executable, but when I use the suggested commands for assembling, linking, and compiling the code, I get errors. Whether I'm using Strawberry Perl's GCC or MinGW's GCC, both give errors for the same YASM/NASM code.
Here are the traces. Either I'm doing something wrong in my Makefile or .ASM, or the linking process is buggy. Either way, I'd like someone to help me resolve the errors.
I get the same result whether I use nasm or yasm to assemble the object file.
Strawberry Perl GCC Trace:
C:\> make
nasm -f win32 -l hello.lst hello.asm
gcc -o hello hello.o
ld: cannot find crt1.o: No such file or directory
ld: cannot find -lmingw32
ld: cannot find -lgcc
ld: cannot find -lmoldname
ld: cannot find -lcrtdll
ld: cannot find -luser32
ld: cannot find -lkernel32
ld: cannot find -ladvapi32
ld: cannot find -lshell32
ld: cannot find -lmingw32
ld: cannot find -lgcc
ld: cannot find -lmoldname
ld: cannot find -lcrtdll
make: *** [hello] Error 1
MinGW GCC Trace:
$ make
gcc -o hello hello.o
c:/mingw/bin/../lib/gcc/mingw32/4.5.2/../../../libmingw32.a(main.o):main.c:(.text+0x104): undefined reference to `WinMain@16'
collect2: ld returned 1 exit status
make: *** [hello] Error 1
Specs:
- YASM 1.2.0
- NASM 2.10.05
- Strawberry Perl gcc 4.4.3
- MinGW gcc 4.5.2
- Strawberry Perl 5.12
- MinGW 0.1
- Windows 7 Professional x64
- MacBook Pro 2009