arm-none-eabi -g ++正在尝试编译桌面而不是arm

时间:2015-07-02 18:26:14

标签: c++ makefile g++ arm

我有一个调用arm-none-eabi-g ++的makefile来编译一堆文件。如果我给文件一个.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

2 个答案:

答案 0 :(得分:0)

我通过确保在makefile中同时设置CC和CXX解决了这个问题:

CC := arm-none-eabi-gcc
CXX := arm-none-eabi-g++

答案 1 :(得分:0)

请注意

之间的差异
objects := ../libc/math.o ...

math.o: ...

制作radio的规则取决于objects,因此取决于../libc/math.o。由于那不存在,Make会寻找建立它的规则。现在,当前目录中的math.o ../libc/math.o不同,因此Make找不到用户定义的规则,最终回落到string sentinalValue = "done"; string input = ""; while (iterations < 1000 && input != sentinalValue) { iterations++; Console.WriteLine("Enter value between 300 to 850."); input = Console.ReadLine(); int value; if (int.TryParse(input, out value)) { if( value < 850 && value > 300 ) { total +=input; } } else { Console.WriteLine("That is not a number!"); } } 。 {3}}(使用$ CC构建“.c”文件,使用$ CXX构建“.cc”文件)。

换句话说,您的自定义规则适用于不相关的目标 - 您可以简单地指定使事情按预期工作的确切路径,但如果您最终想要更通用的内容,则值得查看通配符和模式的方式规则有效。