Make Uses "Cc" Instead of "Arm-None-Eabi-As"

make uses cc instead of arm-none-eabi-as

Try using CC instead of GCC (which is the variable used in the default make rules), but in this case, it uncovered another issue: your rules were ignored.

what's the "%h" supposed to do?

Also note that your "echo" command isn't executed - another hint that your rules aren't considered by make

arm-none-eabi-g++ is trying to compile for desktop instead of arm

Note the discrepancy between

objects := ../libc/math.o ...


math.o: ...

Make has a rule for radio which depends on objects, thus depends on ../libc/math.o. Since that doesn't exist, Make goes looking for a rule to build it. Now, math.o in the current directory is a different thing to ../libc/math.o, so Make finds no user-defined rules for what it wants, and ends up falling back to its implicit rules (which build ".c" files with $CC and ".cc" files with $CXX).

In other words, your custom rules are for irrelevant targets - you can simply specify the exact path to make things work as expected, although if you ultimately want something more general it'd be worth having a look into how wildcards and pattern rules work.

CMake C project does not compile under arm-none-eabi toolchain

You need to use a CMAKE_TOOLCHAIN_FILE instead of your hackish compiler change without any sysroot etc...

-DCMAKE_C_COMPILER:FILEPATH=G:\Program Files (x86)\GNU Arm Embedded Toolchain\10 2021.07\bin\arm-none-eabi-gcc.exe"


Identify Compiler Versions with arm-none-eabi cross compiling

There is no relationship. It is a separate compiler which usually comes with its own include files, libraries, startup file and linker scripts. Usually, it is called a toolchain as often it comes with other tools as well (linker, specific versions of gdb and other tools).

scons error sh: 1: arm-none-eabi-gcc: not found''

This looks like the answer to #1 of our "most frequently asked" FAQs at could help you out. By default, SCons doesn't import the variables like $PATH from the surrounding shell environment. You have to pull in your $PATH for properly detecting the arm-none-eabi-gcc executable or specify the full path to the executable explicitly...check the mentioned FAQ entry for a more detailed discussion about why things are as they are, and how to provide the required $PATH definitions to your build environments.

Cross-compile a library for arm-none-eabi-gcc

I was able to get this working with a couple of extra options specific to that configure script.

Though I didn't realise at the time of asking the question, these vary, so some familiarity or trial and error with the specific options available (./configure --help should always list those available) is required.

I should also note that make check will always fail on the build system, so isn't worthwhile.

linking succeeds with arm-none-eabi-g++ but not arm-none-eabi-gcc

C++ requires that the math functions be part of the basic runtime while C allows them to be in a library. The GCC implementation achieved this by automatically linking libm in a C++ build.

There are many other differences in the link phase; C++ linking will consistently fail if a C linker is used.

For a C link, use the C linker and specify -lm to make libm available.

Issues with makefile

This rule:

$(BUILDDIR)/%.o: %.c

describes to make how to create a file $(BUILDDIR)/foo.o from foo.c. But you now want to compile a .cpp file. Just changing the compiler variable in the recipe from $(CC) to $(CXX) doesn't change description of targets or prerequisites! You need to add a new rule telling make how to compile your .cpp files:

$(BUILDDIR)/%.o: %.cpp
mkdir -p $(dir $@)
$(CXX) -c $(CXXFLAGS) $< -o $@

Also, you should probably put back the $(CC) compile invocation in the %.c recipe; it's generally not a good idea to compile C code with a C++ compiler.

Build is happening by default with g++ instead of arm compiler?

It's impossible to know why you're seeing what you're seeing without the rest of your build system, but here's some general advice:

Don't edit the makefile; pass the value you want on the command line:

make CXX=arm-linux-gnueabihf-g++ <whatever your normal args are>

Command line values override those set inside the file, and usually get passed down to nested makefiles and override all the other confusing stuff that can complicate this.

If that doesn't work, check there isn't a configure script, or something else that you ought to be using instead.

Related Topics

Leave a reply