gnu 和 gnu-arm 编译器可以在同一个系统中共存吗?

问题描述

gnu 和 gnu-arm 编译器可以在同一个系统上共存吗?

我第一次在windows 10上成功运行MinGW32编译windows软件,后来越来越觉得GNU系列软件好用,那为什么不也用GNU-ARM编译stm32呢?但是我无法在 vscode 上使用 cmake 成功编译 stm32,

我遇到的第一个问题是系统变量,GNU和GNU-ARM都需要注册C、C++系统变量,下面是使用GNU-ARM 10编译stm32,但是工作过程显示了信息,vscode还是调用GNU 5.3,(GNU我装的是5.3版本,我装的GNU-ARM是比较新的)版本)

> Executing task: cmake -G 'MinGW Makefiles' L:\000_PROJECT\STM32\Project\vscode\dso138 <

-- The C compiler identification is GNU 5.3.0
-- The CXX compiler identification is GNU 5.3.0
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - failed
-- Check for working C compiler: E:/mingw32/bin/gcc.exe
-- Check for working C compiler: E:/mingw32/bin/gcc.exe - works
-- Detecting C compile features
-- Detecting C compile features - done
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - failed
-- Check for working CXX compiler: E:/mingw32/bin/c++.exe
-- Check for working CXX compiler: E:/mingw32/bin/c++.exe - works
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- MCU_FLAGS: -mcpu=cortex-m3 -mthumb  
-- DBG_FLAGS: -g3 -gdwarf-2 -O0
-- Configuring done
-- Generating done
-- Build files have been written to: L:/000_PROJECT/STM32/Project/vscode/dso138/build

虽然看起来工作正常,但没有错误消息,也没有编译 bin 或 elf 文件。

第二个问题是关于vscode中任务列表的参数,

//task.json

task:[
{
         ...
         {
            /************************************************************************************
             * cmake
             ***********************************************************************************/  
            "label": "cmake","command": "cmake","type": "shell","args": [
                "-G","MinGW Makefiles","${workspaceFolder}"
            ],"group": {
                "kind": "build","isDefault": true
            },"options": {
                "cwd": "${workspaceFolder}/build",},"dependsOn": [
                "build_dir" 
            ]
          },{
            /************************************************************************************
             * make
             ***********************************************************************************/  
            "label": "make","group": "build","command": "make","executable": "E:/gcc_arm/bin/arm-none-eabi-nm.exe"
            },"args": [
                "-j"
            ],"dependsOn": [
                "cmake","del_exe" 
            ]
           }
...
}

我不确定,但问题可能是使用命令引起的:

cmake -G MinGW Makefiles

第三个问题是关于make的命令:

"E:/gcc_arm/bin/arm-none-eabi-nm.exe",

不确定上面的参数是否正确。

感谢您分享您的智慧和经验;

解决方法

近十年来,我使用与系统特定版本 GNU GCC 并行的 GNU Arm 嵌入式工具链,没有任何问题,但在 GNU/Linux 下使用纯 make。

我认为在 Windows 上的解决方案类似于 Linux 案例。使用正确的编译器路径并配置CMake(也许你可以在vscode下进行或尝试直接使用工具)。我为您找到了一个很有用的启动触发器(除了文档):How to specify a compiler in CMake?

相关问答

错误1:Request method ‘DELETE‘ not supported 错误还原:...
错误1:启动docker镜像时报错:Error response from daemon:...
错误1:private field ‘xxx‘ is never assigned 按Alt...
报错如下,通过源不能下载,最后警告pip需升级版本 Requirem...