【发布时间】:2015-08-05 07:38:12
【问题描述】:
我的系统是windows 8.1。我正在使用 cygwin 32 位版本(首先我设置了 64 位版本并且无法完全卸载,后来设置了 32 位版本)。我只是想使用“make”实用程序。我所有的 makefile 扩展名都是“makefile”。 当我在下面尝试这个时(为了看到它们工作,我只使用简单的 makefile)
make kernel.o (in shell)
kernel.o : kernel.c
<tab>gcc - ffreestanding -c $< -o $@
它可以工作,并且可以编译。
但是下面的这些不起作用。并且为了测试目的和保持简单,每个源和相应的 makefile 都在自己的目录中。并且所有 make 命令都在源和相应的 makefile 所在的当前目录中生成。
cygwin 运行配方所需的所有可执行文件(nasm、ld、objcopy、cat)都在同一目录中(即 c:\cygwin\bin\)
如果我从 shell 命令配方,它们就可以工作。 我还更改了源文件,看看会发生什么。
我还认为问题可能出在 cygwin 本身,我在我的机器上设置了 linux ubuntu 桌面版本。但是它们(下面的食谱)也不起作用。(而且如果我从 shell 命令食谱,它们也可以工作。)
make kernel_entry.o (in shell)
make: *** No rule to make target 'kernel_entry.o'.
Rule:
kernel_entry.o : kernel_entry.asm
<tab>nasm $< -o $@ -f coff (coff for windows)
//--------------------------------
make os-image.bin (in shell)
make: *** No rule to make target 'os-image.bin'.
Rule:
os-image.bin: boot.bin kernel.bin
<tab>cat $< > $@
//--------------------------------
make boot.bin
make: *** No rule to make target 'boot.bin'.
Rule :
boot.bin : boot.asm
<tab> nasm $< -f bin -o $@
*recipes with ld and objcopy also does not work.*
提前谢谢你...
这些是我的文件和目录外观:
C:\cygwin\bin --> where gcc.stays
C:\cygwin\bin --> where make.exe stays
C:\cygwin\bin --> where objcopy stays
C:\cygwin\bin --> where nasm.exe stays
C:\cygwin\bin --> where ld stays
C:\cygwin\home\me\OS\boot --> where boot.makefile stays and also boot.asm source code
C:\cygwin\home\me\OS\kernel --> where kern.makefile stays ( working sample ) and also kernel.c source code
这是 cygwin shell 的外观:
me@Me ~/os/kernel
$ dir
kern.makefile kernel.c kernel_entry.asm
**在我的kern.makefile中,现有规则如下
kernel_entry.o : kernel_entry.asm
nasm $< -o $@ -f coff
和引导目录
me@Me ~/os/boot
$ dir
boot.asm disk_load.asm print_hex.asm print_string_pm.asm
boot.makefile gdt.asm print_string.asm switch_to_pm.asm
**在我的 boot.makefile 中,现有规则如下
boot.bin : boot.asm
nasm $< -f bin -o $@
【问题讨论】:
-
查看实际的目录布局、实际的 Makefile 和实际的命令(包括工作目录)会有所帮助。
-
谢谢@DevSolar。我编辑(添加目录外观)到我的问题。不过,我没有看到任何问题。如果你能看到,请警告。
-
我想补充一点,我已经直接从 windows 和 cygwin shell(nasm、gcc、ld、objcopy)编译了这些源代码,没有 make 实用程序并将其写入闪存盘,然后启动机器并进入保护模式没有任何问题。
-
好吧,如果您看到目录布局的问题,您就不必来这里询问了。 ;-)