[英]arm-none-eabi-g++ is trying to compile for desktop instead of arm
我有一个生成文件,调用arm-none-eabi-g ++来编译一堆文件。 如果我给文件加.c扩展名,它就可以工作。 如果我将扩展名更改为.cc,则似乎g ++正在执行编译,而不是arm-none-eabi-g ++。 我指定-mcpu = cortex-m0 -mthumb。 这是makefile:
CXX := arm-none-eabi-g++
# -I/usr/lib/arm-none-eabi/include\: since we're compiling with nostdinc and nostdlib, include this directory to grab necessary files
CFLAGS := \
-nostdinc\
-I.\
-I../arch/cortex-m0+\
-I../devices\
-I../libc\
-I/usr/lib/arm-none-eabi/include\
-O0\
-ffunction-sections\
-fdata-sections\
-Wall\
-fmessage-length=0\
-mcpu=cortex-m0\
-mthumb\
-mfloat-abi=soft\
-gdwarf-2\
-g3\
-gstrict-dwarf\
-Wno-unused-but-set-variable\
-Wno-attributes\
-fno-builtin\
-fno-exceptions
objects := \
../libc/math.o\
../libc/malloc.o
radio : $(objects)
math.o : ../libc/math.c ../libc/math.h
$(CXX) $(CFLAGS) -c ../libc/math.c
malloc.o : ../libc/malloc.cc ../libc/malloc.hh
$(CXX) $(CFLAGS) -c ../libc/malloc.cc
clean :
rm radio.elf radio.map $(objects)
这是make的输出:
marlon@marlon-Z68X-UD3H-B3:~/projects/firmware$ make
cc -nostdinc -I. -I../arch/cortex-m0+ -I../devices -I../libc -I/usr/lib/arm-none-eabi/include -O0 -ffunction-sections -fdata-sections -Wall -fmessage-length=0 -mcpu=cortex-m0 -mthumb -mfloat-abi=soft -gdwarf-2 -g3 -gstrict-dwarf -Wno-unused-but-set-variable -Wno-attributes -fno-builtin -fno-exceptions -c -o ../libc/math.o ../libc/math.c
cc: warning: ‘-mcpu=’ is deprecated; use ‘-mtune=’ or ‘-march=’ instead
cc: error: unrecognized command line option ‘-mthumb’
cc: error: unrecognized command line option ‘-mfloat-abi=soft’
make: *** [../libc/math.o] Error 1
我通过确保在makefile中设置CC和CXX来解决了这个问题:
CC := arm-none-eabi-gcc
CXX := arm-none-eabi-g++
请注意之间的差异
objects := ../libc/math.o ...
和
math.o: ...
Make的radio
规则取决于objects
,因此取决于../libc/math.o
。 既然不存在,Make就去寻找建立规则。 现在, math.o
在当前目录是不同的东西../libc/math.o
,所以要认定它想要的东西没有用户定义的规则,并最终回落至其隐含规则 (其中建设”。带有$ CC的c“文件和带有$ CXX的” .cc“文件)。
换句话说,您的自定义规则适用于不相关的目标-您可以简单地指定使事情按预期工作的确切路径,尽管如果您最终想要更通用的内容,则值得一看通配符和模式规则的工作方式。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.