Search code examples
cmakestm32gnugnu-arm

Is it possible for gnu and gnu-arm compilers to coexist on the same system?


Is it possible to have gnu and gnu-arm compilers coexist on the same system?

I first ran MinGW32 successfully on windows 10 to compile windows software, then I felt more and more that GNU series software is good to use, so why don't to use GNU-ARM to compile even stm32 too ? but I couldn't compile stm32 successfully with cmake on vscode,

The first problem I encountered was the system variables, both GNU and GNU-ARM need to register the C, C++ system variables, the following is to use GNU-ARM 10 to compile stm32, but the work process shows me the information, vscode is still calling GNU 5.3, (GNU I installed the 5.3 version, and GNU-ARM I installed is relatively new) version)

> 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

Although it seems to work fine, with no error messages, no bin or elf files are compiled.

The second problem is about parameters of task list in 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",
            "type": "shell",
            "command": "make",
            "options": {
                "cwd": "${workspaceFolder}/build",
                "executable": "E:/gcc_arm/bin/arm-none-eabi-nm.exe"
            },
            "args": [
                "-j"
            ],
            "dependsOn": [
                "cmake",
                "del_exe" 
            ]
           }
...
}

I am not sure, but the problem may be caused by using the command:

cmake -G MinGW Makefiles

The third problem is about the command of make:

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

not sure if the parameters above is correct.

Thank you for sharing your wisdom and experience;


Solution

  • For almost a decade I use GNU Arm embedded toolchain parallel with system-specific version GNU GCC, without any problem, but under GNU/Linux with pure make.

    I think on Windows the solution is similar to the Linux case. Use the right path to the compiler and configure CMake (maybe you can do it under vscode or try to use tools directly). I found a hopefully useful starting trigger (besides the documentation) for you: How to specify a compiler in CMake?