过去几天我一直试图在 Linux 上使用Eclipse设置GNU ARM插件。 问题是我无法为我的STM32 Discovery F4板正确编译。 编译普通的gcc ARM项目没有问题,但是当谈到STM32F4xx时,我遇到了这些错误:
13:26:22 **** Incremental Build of configuration Release for project F4Test ****
make all
Building file: ../system/src/newlib/_cxx.cpp
Invoking: Cross ARM C++ Compiler
arm-none-eabi-g++ -mcpu=cortex-m4 -mthumb -mfloat-abi=soft -Os -fmessage-length=0 -fsigned-char -ffunction-sections -fdata-sections -Wall -Wextra -g -DOS_USE_TRACE_ITM -DSTM32F407xx -DUSE_HAL_DRIVER -DHSE_VALUE=8000000 -I"../include" -I"../system/include" -I"../system/include/cmsis" -I"../system/include/stm32f4-hal" -std=gnu++11 -fabi-version=0 -fno-exceptions -fno-rtti -fno-use-cxa-atexit -fno-threadsafe-statics -MMD -MP -MF"system/src/newlib/_cxx.d" -MT"system/src/newlib/_cxx.o" -c -o "system/src/newlib/_cxx.o" "../system/src/newlib/_cxx.cpp"
../system/src/newlib/_cxx.cpp:13:19: fatal error: cstdlib: No such file or directory
#include <cstdlib>
^
compilation terminated.
make: *** [system/src/newlib/_cxx.o] Error 1
13:26:22 Build Finished (took 69ms)
我的代码是默认导致闪烁的一个:
//
// This file is part of the GNU ARM Eclipse distribution.
// Copyright (c) 2014 Liviu Ionescu.
//
// ----------------------------------------------------------------------------
#include <stdio.h>
#include "Timer.h"
#include "BlinkLed.h"
// ----------------------------------------------------------------------------
//
// STM32F4 led blink sample (trace via ITM).
//
// In debug configurations, demonstrate how to print a greeting message
// on the trace device. In release configurations the message is
// simply discarded.
//
// To demonstrate POSIX retargetting, reroute the STDOUT and STDERR to the
// trace device and display messages on both of them.
//
// Then demonstrates how to blink a led with 1Hz, using a
// continuous loop and SysTick delays.
//
// On DEBUG, the uptime in seconds is also displayed on the trace device.
//
// Trace support is enabled by adding the TRACE macro definition.
// By default the trace messages are forwarded to the ITM output,
// but can be rerouted to any device or completely suppressed, by
// changing the definitions required in system/src/diag/trace_impl.c
// (currently OS_USE_TRACE_ITM, OS_USE_TRACE_SEMIHOSTING_DEBUG/_STDOUT).
//
// ----- Timing definitions -------------------------------------------------
// Keep the LED on for 2/3 of a second.
#define BLINK_ON_TICKS (TIMER_FREQUENCY_HZ * 2 / 3)
#define BLINK_OFF_TICKS (TIMER_FREQUENCY_HZ - BLINK_ON_TICKS)
// ----- main() ---------------------------------------------------------------
// Sample pragmas to cope with warnings. Please note the related line at
// the end of this function, used to pop the compiler diagnostics status.
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wunused-parameter"
#pragma GCC diagnostic ignored "-Wmissing-declarations"
#pragma GCC diagnostic ignored "-Wreturn-type"
int
main(int argc, char* argv[])
{
// By customising __initialize_args() it is possible to pass arguments,
// for example when running tests with semihosting you can pass various
// options to the test.
// trace_dump_args(argc, argv);
// Send a greeting to the trace device (skipped on Release).
trace_puts("Hello ARM World!");
// The standard output and the standard error should be forwarded to
// the trace device. For this to work, a redirection in _write.c is
// required.
puts("Standard output message.");
fprintf(stderr, "Standard error message.\n");
// At this stage the system clock should have already been configured
// at high speed.
trace_printf("System clock: %uHz\n", SystemCoreClock);
timer_start();
blink_led_init();
uint32_t seconds = 0;
// Infinite loop
while (1)
{
blink_led_on();
timer_sleep(BLINK_ON_TICKS);
blink_led_off();
timer_sleep(BLINK_OFF_TICKS);
++seconds;
// Count seconds on the trace device.
trace_printf("Second %u\n", seconds);
}
// Infinite loop, never return.
}
#pragma GCC diagnostic pop
// ----------------------------------------------------------------------------
我尝试将cstdlib文件添加到项目中,但后来又出现了新的错误。 谢谢你的帮助!