我正在尝试将hello.asm构建到 Windows 可执行文件中,但是当我使用建议的命令来组装、链接和编译代码时,我得到了错误。无论我使用的是Strawberry Perl的 GCC 还是MinGW的 GCC,都会对相同的 YASM/NASM 代码给出错误。
这是痕迹。要么我在 Makefile 或 .ASM 中做错了,要么链接过程有问题。无论哪种方式,我都希望有人帮助我解决错误。
无论我使用 nasm 还是 yasm 来组装目标文件,我都会得到相同的结果。
草莓 Perl GCC 跟踪:
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 跟踪:
$ 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
眼镜:
- 雅思 1.2.0
- NASM 2.10.05
- 草莓 Perl gcc 4.4.3
- MinGW gcc 4.5.2
- 草莓 Perl 5.12
- MinGW 0.1
- Windows 7 专业版 x64
- MacBook Pro 2009