链接用于将.o文件转换为.elf的参数

时间:2011-10-12 14:44:05

标签: makefile arm cross-compiling

我有六个源文件,我想使用.elf格式链接它们。我编写了一个makefile,将所有源代码文件转换为.obj文件。

当我尝试使用makefile中提供的语法链接这些目标文件时,会出现以下错误:

gcc -c rt_look.c
Linking ARM test_rom.elf
make[1]: o: Command not found
make[1]: [test_rom.elf] Error 127 (ignored)
make[1]: Leaving directory `/c/Imperas/Demo/main/isolated_model_ert_rtw

我也粘贴了makefile规则:

all:$(OBJ) test_rom.elf 

ert_main.o:              ert_main.c isolated_model.h rtwtypes.h
             gcc -c ert_main.c
isolated_model.o:        isolated_model.c isolated_model.h isolated_model_private.h
             gcc -c isolated_model.c
isolated_model_date.o:   isolated_model_data.c isolated_model.h isolated_model_data.h
             gcc -c isolated_model_data.c
rt_look2d_normal.o:      rt_look2d_normal.c rtlibsrc.h
             gcc -c rt_look2d_normal.c
rt_nonfinite.o:          rt_nonfinite.c rt_nonfinite.h
             gcc -c rt_nonfinite.c
rt_look.o:           rt_look.c rtlibsrc.h
             gcc -c rt_look.c
syscalls.o:          syscalls.c
             gcc -c syscalls.c
test_rom.elf:        $(OBJ) 
                     $(V) echo "Linking $(CROSS) $@"
                     $(V) $(IMPERAS_LINK) -o $@ $^ $(IMPERAS_LDFLAGS) -lm

clean::
-rm -f test_rom.elf
-rm -f *.$(OBJ).o

endif

1 个答案:

答案 0 :(得分:2)

VIMPERAS_LINK变量未设置或设置为空值,因此在构建test_rom.elf时,make运行命令

 -o $@ $^ $(IMPERAS_LDFLAGS) -lm

尝试运行o命令。由于命令中的第一个字符是-make会忽略错误。

尝试将"Linking $(CROSS)"替换为"Linking $(CROSS) with $(IMPERAS_LINK)"以查看是否属实。

相关问题