【问题标题】:How to point VS2017 to the (arm-none-eabi-) gcc default headers when using cmake使用cmake时如何将VS2017指向(arm-none-eabi-)gcc默认标头
【发布时间】:2019-07-26 05:58:00
【问题描述】:

我正在尝试使用 VS2017(和 VS2019RC/preview)构建一个项目/测试 cmake,使用 arm-none-eabi-gcc 作为我的编译器。

我很难告诉 VS2017 在哪里寻找默认的 gcc 标头。

实现这一目标的正确/最简单的方法是什么?

【问题讨论】:

  • 也许有工具链文件?
  • 我试过这个。无济于事。通过CMakeSettings.json 的cmakeToolchain 参数或作为variables 在同一个.json 文件中

标签: gcc cmake visual-studio-2017 visual-studio-2019


【解决方案1】:

我知道我可以像常规包含一样包含它们,但尝试查找配置选项并在下面找到有关如何将其推送到 INCLUDE env 变量的链接。

https://devblogs.microsoft.com/cppblog/arm-gcc-cross-compilation-in-visual-studio/

您可以指定额外的包含目录,但请注意,如果存在子目录,此时也必须显式声明。

[code lang=”js”]
{
// The "environments" property is an array of key value pairs of the form
// { "EnvVar1": "Value1", "EnvVar2": "Value2" }
"environments": [
{
"INCLUDE": "${workspaceRoot}\\src\\includes"
}
],

{
  "configurations": [
    {
      "inheritEnvironments": [
        "gcc-arm"
      ],
      "name": "gccarm",
      "includePath": [
        "${env.INCLUDE}"
      ],
      "defines": [
      ]
    }
  ]
}

【讨论】:

  • 您好,很抱歉没有及时回复您,但很遗憾这不起作用。什么有效,但不是解决方案(真正的解决方案)是在我的 cmake 文件中指定包含路径。我现在会回答我自己的问题,但不会接受。
【解决方案2】:

所以我有一个解决方法,很好,行得通。但这绝对不是长久之计。

我所做的是直接在CMakeLists.txttarget_include_directories 指令中添加了GCC 包含路径,这很有效。像这样:

target_include_directories(
    ${ELF}
    PRIVATE
        "source"
        "source/target/arm/stm32f1/CMSIS/Device/ST/STM32F1xx/Include"
        "${tools}\\bin\\../lib/gcc/arm-none-eabi/7.3.1/../../../../arm-none-eabi/include/c++/7.3.1"
        "${tools}\\bin\\../lib/gcc/arm-none-eabi/7.3.1/../../../../arm-none-eabi/include/c++/7.3.1/arm-none-eabi"
        "${tools}\\bin\\../lib/gcc/arm-none-eabi/7.3.1/../../../../arm-none-eabi/include/c++/7.3.1/backward"
        "${tools}\\bin\\../lib/gcc/arm-none-eabi/7.3.1/include"
        "${tools}\\bin\\../lib/gcc/arm-none-eabi/7.3.1/include-fixed"
        "${tools}\\bin\\../lib/gcc/arm-none-eabi/7.3.1/../../../../arm-none-eabi/include"
)

但是,没有人想要这样的解决方案。那么如果有人有更好的主意呢?

【讨论】:

    猜你喜欢
    • 2017-03-24
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2023-04-05
    • 1970-01-01
    • 2016-05-01
    • 2017-10-10
    • 2020-07-16
    相关资源
    最近更新 更多