stm32 HAL库eclipse

stm32 HAL library eclipse

我正在使用带有 ARM 插件的 Eclipse IDE 在我的 F4-Discovery 上开发一个项目。我创建了一个空模板项目并开始使用 stm32 HAL 库中的函数,但出现如下错误:

undefined reference to `HAL_DMA_Init'

undefined reference to `HAL_UART_Init'

必要的 .c 和 .h 文件在正确的目录中,但 Eclipse 只识别了一半的 .c 文件,其他的被划掉了。 This image explains my problem. 怎么了?谢谢

您需要向 Eclipse 添加包含路径 CDT。假设这是一个托管构建(而不是使用外部 Makefile),您需要按照说明进行操作 here.

Adding Include paths and symbols in Managed Build System

For CDT projects, you can define include paths and preprocessor symbols for the parser. This lets the parser understand the contents of the C/C++ source code so that you can more effectively use the search and code completion features.

If Autodiscovery is enabled, after a build finishes, any discovered paths and symbols will be displayed in the Discovered Paths section. You can also define the properties on a per project basis in the C/C++ Projects or Navigator views.

To add include paths and symbols:

To set properties for your project, right-click your CDT project and select Properties. Alternatively, to set properties for a specific source file in your project, right-click a source file within your make project and select Properties.

  1. Expand C/C++ General and select Paths and Symbols.

  2. Click here to see an illustration (displayed in a separate window).

  3. Click Add to define new element (Include Path, Symbol, Library path etc).

  4. Click Edit to change selected element (Include Path, Symbol, Library path etc).
  5. Click Delete to remove selected element (Include Path, Symbol, Library path etc).
  6. Click Export to make selected element (Include Path, Symbol, Library path etc) exported.
  7. Click Unexport to remove selected element (Include Path, Symbol, Library path etc) from export list.
  8. Click Move up and Move down to set elements (Include Paths, Library paths etc) order.

在您需要的文件的属性 (Alt+Enter) 中,勾选 "Exclude resource from build" 复选框。 as shown in this link

"Undefined reference" 可能是链接器错误。您没有编译您尝试使用的库的实际源代码。

转到 system > src > stm32f4-hal,然后右键单击您要包含的库文件。取消选中 "exclude from build."