element14 Community
element14 Community
    Register Log In
  • Site
  • Search
  • Log In Register
  • Community Hub
    Community Hub
    • What's New on element14
    • Feedback and Support
    • Benefits of Membership
    • Personal Blogs
    • Members Area
    • Achievement Levels
  • Learn
    Learn
    • Ask an Expert
    • eBooks
    • element14 presents
    • Learning Center
    • Tech Spotlight
    • STEM Academy
    • Webinars, Training and Events
    • Learning Groups
  • Technologies
    Technologies
    • 3D Printing
    • FPGA
    • Industrial Automation
    • Internet of Things
    • Power & Energy
    • Sensors
    • Technology Groups
  • Challenges & Projects
    Challenges & Projects
    • Design Challenges
    • element14 presents Projects
    • Project14
    • Arduino Projects
    • Raspberry Pi Projects
    • Project Groups
  • Products
    Products
    • Arduino
    • Avnet Boards Community
    • Dev Tools
    • Manufacturers
    • Multicomp Pro
    • Product Groups
    • Raspberry Pi
    • RoadTests & Reviews
  • Store
    Store
    • Visit Your Store
    • Choose another store...
      • Europe
      •  Austria (German)
      •  Belgium (Dutch, French)
      •  Bulgaria (Bulgarian)
      •  Czech Republic (Czech)
      •  Denmark (Danish)
      •  Estonia (Estonian)
      •  Finland (Finnish)
      •  France (French)
      •  Germany (German)
      •  Hungary (Hungarian)
      •  Ireland
      •  Israel
      •  Italy (Italian)
      •  Latvia (Latvian)
      •  
      •  Lithuania (Lithuanian)
      •  Netherlands (Dutch)
      •  Norway (Norwegian)
      •  Poland (Polish)
      •  Portugal (Portuguese)
      •  Romania (Romanian)
      •  Russia (Russian)
      •  Slovakia (Slovak)
      •  Slovenia (Slovenian)
      •  Spain (Spanish)
      •  Sweden (Swedish)
      •  Switzerland(German, French)
      •  Turkey (Turkish)
      •  United Kingdom
      • Asia Pacific
      •  Australia
      •  China
      •  Hong Kong
      •  India
      •  Korea (Korean)
      •  Malaysia
      •  New Zealand
      •  Philippines
      •  Singapore
      •  Taiwan
      •  Thailand (Thai)
      • Americas
      •  Brazil (Portuguese)
      •  Canada
      •  Mexico (Spanish)
      •  United States
      Can't find the country/region you're looking for? Visit our export site or find a local distributor.
  • Translate
  • Profile
  • Settings
Embedded and Microcontrollers
  • Technologies
  • More
Embedded and Microcontrollers
Blog Raspberry Pico C/C++ SDK - Set up C++23 capable toolchain
  • Blog
  • Forum
  • Documents
  • Quiz
  • Polls
  • Files
  • Members
  • Mentions
  • Sub-Groups
  • Tags
  • More
  • Cancel
  • New
Join Embedded and Microcontrollers to participate - click to join for free!
  • Share
  • More
  • Cancel
Group Actions
  • Group RSS
  • More
  • Cancel
Engagement
  • Author Author: Jan Cumps
  • Date Created: 2 Aug 2024 2:06 PM Date Created
  • Views 2361 views
  • Likes 6 likes
  • Comments 1 comment
  • raspberry
  • pico
  • c++23
  • OO
  • c++
  • teseo_c++
  • toolchain
Related
Recommended

Raspberry Pico C/C++ SDK - Set up C++23 capable toolchain

Jan Cumps
Jan Cumps
2 Aug 2024

The Pico C/C++ SDK 1.5, when installed with the windows installer, comes with GCC version 10.3.1. That version supports C++ up to C++2a. Any GCC with version > 10 supports C++23.
In this little post, I install GCC 13.3, build my project with it, and validate it with the SDK (and VSCode).

The easiest way to do this, is to install the ARM cross compiler for arm bare metal. If you accept all default settings, this toolchain will be auto-detected by VSCode on next start.

Download the installer from https://developer.arm.com/downloads/-/arm-gnu-toolchain-downloads. Look for the Windows (mingw-w64-i686) hosted cross toolchains  AArch32 bare-metal target (arm-none-eabi) section. Execute the installer. When prompted, leave the check for "configure registry settings" on. If you know what you are doing, you can alter other settings. When unsure, accept all defaults.

Restart VSCode. When defining the build, you can now select the new 13.3 toolchain:

image

To enable the C++23 standard, maintain the relevant setting in your project CMake file:

project(pico_gps_teseo C CXX ASM)

set(CMAKE_C_STANDARD 11)
set(CMAKE_CXX_STANDARD 23)

pico_sdk_init()

I tested it for this project, that needs C++23:  C++ parser library for NMEA GPS data - pt. 1: ideas, concepts, early design 

image

As extra test, I also built all the examples of the SDK 1.5 Pico examples:

[build] [6377/6377 100% :: 206.086] Linking CXX executable watchdog\hello_watchdog\hello_watchdog.elf
[driver] Build completed: 00:03:26.155
[build] Build finished with exit code 0

The install is non-intrusive, except if you let it change the path. You can either uncheck that option if you don't want that. Or remove the gcc13.3.1 bin directory from your path later on, via your Windows settings.
In any case, you will still be able to select and use the original GCC 10.3.1 that comes with the Pico SDK.

Jan, I don't use VSCode!

Other IDEs will have similar methods to select the new toolchain.

If you use command line, you can select the new toolchain via the parameters (works for Linux and Windows, as long as you use forward slashes for the path separator):

mkdir build
cd build
cmake .. -DCMAKE_EXPORT_COMPILE_COMMANDS:BOOL=TRUE -DCMAKE_C_COMPILER:FILEPATH=/opt/gcc-arm-none-eabi/bin/arm...

Also works if you're building on a GitHub hosted server via GitHub Actions (see 1st comment below):

image
  • Sign in to reply

Top Comments

  • Jan Cumps
    Jan Cumps 11 months ago +1
    The github repository that I use for the project I used above, validates if your (my ) code builds, when a pull request is made for the develop or main branch: GitHub: automate Raspberry Pico project build…
  • Jan Cumps
    Jan Cumps 11 months ago

    The github repository that I use for the project I used above, validates if your (my Slight smile) code builds, when a pull request is made for the develop or main branch: GitHub: automate Raspberry Pico project build verification with GitHub Actions 

    This verification runs on GitHub hosted virtual machines.

    The GitHub action installed the default version of the GCC cross-compile toolchain for the Linux server that the action happens to run on:

          - name: Install dependencies
            run: |
              sudo apt-get install cmake
    
               sudo apt install gcc-arm-none-eabi
               /usr/bin/arm-none-eabi-gcc --version

    At this moment, that's version 10.3. Not high enough to compile C++23 constructs.

    I adapted the build file to download and install the most recent version of the toolchain:

          - name: Install dependencies
            run: |
              sudo apt-get install cmake
              curl -Lo gcc-arm-none-eabi.tar.xz "https://developer.arm.com/-/media/Files/downloads/gnu/13.3.rel1/binrel/arm-gnu-toolchain-13.3.rel1-x86_64-arm-none-eabi.tar.xz"
              sudo mkdir /opt/gcc-arm-none-eabi
              sudo tar xf gcc-arm-none-eabi.tar.xz --strip-components=1 -C /opt/gcc-arm-none-eabi
              echo 'export PATH=$PATH:/opt/gcc-arm-none-eabi/bin' | sudo tee -a /etc/profile.d/gcc-arm-none-eabi.sh
              export PATH=$PATH:/opt/gcc-arm-none-eabi/bin
              export PICO_TOOLCHAIN_PATH=/opt/gcc-arm-none-eabi/bin
              source /etc/profile
              arm-none-eabi-c++ --version
              

    I then adapted the build section to find the toolchain:

    - name: Build Project
      working-directory: ${{github.workspace}}/pico_gps_teseo
      shell: bash
      run: |
        mkdir build
        cd build
        cmake .. -G "Unix Makefiles" -DCMAKE_EXPORT_COMPILE_COMMANDS:BOOL=TRUE -DCMAKE_C_COMPILER:FILEPATH=/opt/gcc-arm-none-eabi/bin/arm...

    It works:

    PICO compiler is pico_arm_gcc
    -- The C compiler identification is GNU 13.3.1
    -- The CXX compiler identification is GNU 13.3.1
    [ 50%] Linking CXX executable pico_gps_teseo_reply_response.elf
    [ 50%] Built target pico_gps_teseo_reply_response
    ...
    [ 92%] Linking CXX executable pico_gps_teseo_nmea_parse.elf
    [ 92%] Built target pico_gps_teseo_nmea_parse
    • Cancel
    • Vote Up +1 Vote Down
    • Sign in to reply
    • More
    • Cancel
element14 Community

element14 is the first online community specifically for engineers. Connect with your peers and get expert answers to your questions.

  • Members
  • Learn
  • Technologies
  • Challenges & Projects
  • Products
  • Store
  • About Us
  • Feedback & Support
  • FAQs
  • Terms of Use
  • Privacy Policy
  • Legal and Copyright Notices
  • Sitemap
  • Cookies

An Avnet Company © 2025 Premier Farnell Limited. All Rights Reserved.

Premier Farnell Ltd, registered in England and Wales (no 00876412), registered office: Farnell House, Forge Lane, Leeds LS12 2NE.

ICP 备案号 10220084.

Follow element14

  • X
  • Facebook
  • linkedin
  • YouTube