【问题标题】:Can't find header file with cmakecmake找不到头文件
【发布时间】:2015-04-28 12:41:28
【问题描述】:

我正在尝试为 nRF51422 芯片编译一个“blinky”程序,并且我一直在 Cygwin 中使用 CMake 来创建 makefile。 (请记住,我是新手。)

这是我的 CMakeLists:

cmake_minimum_required(VERSION 2.8 FATAL_ERROR)
set(CMAKE_LEGACY_CYGWIN_WIN32 0)

project("nRF51422 Blinky" C)

add_executable(nRF51 main.c)
target_include_directories(nRF51 PUBLIC "X:/Documents/TestCompilation/RTE")
target_include_directories(nRF51 PUBLIC "X:/Programs/Keil_v5/ARM/Pack/ARM/CMSIS/4.2.0/CMSIS/Include")
target_include_directories(nRF51 PUBLIC "X:/Programs/Keil_v5/ARM/Pack/NordicSemiconductor/nRF_DeviceFamilyPack/1.1.4/Device/Include")
target_include_directories(nRF51 PUBLIC "X:/Programs/Keil_v5/ARM/Pack/NordicSemiconductor/nRF_Drivers/1.2.1/hal")
target_include_directories(nRF51 PUBLIC "X:/Programs/Keil_v5/ARM/Pack/NordicSemiconductor/nRF_Examples/7.2.0/bsp")

运行 cmake -G"Unix Makefiles" && make 时出现此错误:

~/blinky/main.c:24:23: fatal error: nrf_delay.h: No such file or directory
#include "nrf_delay.h"
                      ^
compilation terminated

我知道 nrf_delay 位于 /nRF_Drivers/1.2.1/hal 文件夹中,那我做错了什么?

【问题讨论】:

  • 您能否检查编译器调用命令行以查看传入的实际-I 是什么?
  • 附带说明,您应该至少需要 CMake 2.8.11,target_include_directories() 在此版本之前不存在。
  • 已编辑错误描述:cmake 运行良好,但是当我运行 make @Angew 更新到 2.8.11 时出现错误 - 结果相同。以及如何检查包含内容?
  • 您确定文件名吗?你确定路径吗?
  • 我看到 nrf_delay.h 位于 \components\drivers_nrf\hal 中的帖子

标签: c cmake embedded nrf51


【解决方案1】:

如前所述:

  • 使用make -j1 VERBOSE=1 构建您的项目-j1 使用一个线程构建,旨在将编译器输出和错误消息保持在一起
  • 必须更正错误消息之前的编译器调用
  • 查看包含并使用您期望的路径重新运行它

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2022-11-11
    • 2021-04-12
    • 1970-01-01
    • 1970-01-01
    • 2018-12-05
    相关资源
    最近更新 更多