Problems with compilation

Problems with compilation:

…/…/libraries/AP_HAL_ChibiOS/UARTDriver.cpp:466:9: fatal error: use of undeclared identifier ‘vprintf_console_hook’
vprintf_console_hook = hal_console_vprintf;

^
6 warnings and 1 error generated.

Code Version, platform, configuration, target board, vehicle type ?

Code Version: Copter-4.3.-
platform: ubuntu
configuration: CC=clang CXX=clang++ CXXFLAGS="-O0 -g --target=arm-none-eabi -I/opt/gcc-arm-none-eabi-10-2020-q4-major/bin/../lib/gcc/arm-none-eabi/10.2.1/../../../../arm-none-eabi/include/c++/10.2.1 -I/opt/gcc-arm-none-eabi-10-2020-q4-major/bin/../lib/gcc/arm-none-eabi/10.2.1/../../../../arm-none-eabi/include/c++/10.2.1/arm-none-eabi -I/opt/gcc-arm-none-eabi-10-2020-q4-major/bin/../lib/gcc/arm-none-eabi/10.2.1/../../../../arm-none-eabi/include/c++/10.2.1/backward -I/opt/gcc-arm-none-eabi-10-2020-q4-major/bin/../lib/gcc/arm-none-eabi/10.2.1/include -I/opt/gcc-arm-none-eabi-10-2020-q4-major/bin/../lib/gcc/arm-none-eabi/10.2.1/include-fixed -I/opt/gcc-arm-none-eabi-10-2020-q4-major/bin/../lib/gcc/arm-none-eabi/10.2.1/../../../../arm-none-eabi/include" ./waf configure --board=CUAVv5
target board: CUAVv5
vehicle type: copter

Did you changed anything in the code ? 4.3 is compile just fine for me.
‘vprintf_console_hook is defined in libraries/AP_HAL_ChibiOS/stdio.h is it included in your code ?

I didn’t change my code, I can find it in my “libraries/AP_HAL_ChibiOS/stdio.h” file, but it still gives this error!

have you updated submodules:

git submodule update --init --recursive

1 Like

Thanks for the suggestion, I used "git submodule update --init --recursive" but the problem persists.

Can you try the following:

  • Using waf, GCC the normal way for SITL.
  • Using waf, GCC for CUAVv5
  • Using waf, clang the normal way for SITL

By the normal way: https://github.com/ArduPilot/ardupilot/blob/master/BUILD.md

I can compile all three successfully.

Is it possible that there is a compatibility issue with clang? I was able to compile with arm-none-eabi-gcc. But when I switch to clang for cross-compilation, I first need to tell the compiler that the library in arm-none-eabi-gcc uses the -I option, and I get an error like this.

I would do a full reset.
Clone the 4.3 branch, do a submodule update and run the environment setup from the 4.3 branch. There were quite some changes in the build environment since 4.3…

As you said I will try to switch to the lower version to the code and hopefully be able to pass.

hello,
I encountered the following problem:
”In file included from …/…/libraries/AP_HAL_ChibiOS/Scheduler.cpp:30:
…/…/libraries/AP_HAL_ChibiOS/CANIface.h:240:44: fatal error: constexpr variable ‘Can’ must be initialized by a constant expression
static constexpr bxcan::CanType* const Can[HAL_NUM_CAN_IFACES] = { HAL_CAN_BASE_LIST };“
I would like to know why arm-none-eabi-gcc doesn’t report this error?

I would like to know why arm-none-eabi-gcc doesn’t report this error?
This error is only prompted when using clang.

Sorry, it’s a different compiler than everyone is using on ChibiOS, I don’t personally have the bandwidth to support it. It’s not something we currently support.

That said, I’m sure if you were interested to get it working, and could prove it out and submit a PR, and enforce it in CI, that would happily be accepted. It’s always good to compile the code against multiple compilers because they return different results, and clang is a bit more strict than gcc.

As far as why specific compilers return different results; well that’s because they are different. Even on SITL, the compilers return different results, and they change from version to version.