I have a Raspberry Pi (3) with a Pico SDK freshly installed via the recommended script.

I've added the pico-project-generator and created a project as follows:

./pico-project-generator/pico_project.py myProject

That empty project builds fine:

cd myProject/build
cmake ..

I then make the following changes, in anticipation of writing + using some C++ classes as the project expands:

cd $projectRoot
mv myProject.c myProject.cpp

<also edit CMakeLists.txt to reflect that file rename>

The previous cmake .. ; make now produces the following errors:

In file included from /usr/include/newlib/stdio.h:35:0,
                 from /home/pi/pico/myProject/myProject.cpp:1:
/home/pi/pico/pico-sdk/src/rp2_common/pico_platform/include/pico/platform.h:237:31: error: duplicate 'inline'
 #define __force_inline inline __always_inline
/home/pi/pico/pico-sdk/src/rp2_common/pico_platform/include/pico/platform.h:282:1: note: in expansion of macro '__force_inline'
 __force_inline static void __compiler_memory_barrier(void) {

<repeats a total of 8 times>

make[2]: *** [CMakeFiles/myProject.dir/build.make:63: CMakeFiles/myProject.dir/myProject.cpp.obj] Error 1
make[1]: *** [CMakeFiles/Makefile2:1559: CMakeFiles/myProject.dir/all] Error 2
make: *** [Makefile:84: all] Error 2

From the official pi-pico-sdk PDF:

The SDK has a C style API, however the SDK headers may be safely included from C++ code, and the functions called (they are declared with C linkage).

C++ files are integrated into SDK projects in the same way as C files: listing them in your CMakeLists file under either the add_executable() entry, or a separate target_sources() entry to append them to your target.

... which suggests to me that there should be nothing extra/different that I need to do.

The fact that /usr/include/newlib/stdio.h appears in the output is sounding alarm bells, but I don't know how to identify how/why that version of stdio.h is being used.

This first came to light when a project I wrote months ago would no longer build on this just-re-imaged Pi. The steps above describe the minimal way of triggering the error.

The only code in the project right now is that generated by the pico-project-generator template: myProject.cpp

#include <stdio.h>
#include "pico/stdlib.h"

int main()

    puts("Hello, world!");

    return 0;


# Generated Cmake Pico project file

cmake_minimum_required(VERSION 3.13)


# initalize pico_sdk from installed location
# (note this can come from environment, CMake cache etc)
set(PICO_SDK_PATH "/home/pi/pico/pico-sdk")

# Pull in Raspberry Pi Pico SDK (must be before project)

project(myProject C CXX ASM)

# Initialise the Raspberry Pi Pico SDK

# Add executable. Default name is the project name, version 0.1

add_executable(myProject myProject.cpp )

pico_set_program_name(myProject "myProject")
pico_set_program_version(myProject "0.1")

pico_enable_stdio_uart(myProject 1)
pico_enable_stdio_usb(myProject 0)

# Add the standard library to the build
target_link_libraries(myProject pico_stdlib)



I had kept a .tgz of my entire /home/pi from before re-imaging the Pi. Restoring the older pico SDK from that alongside the new one and switching between them via PICO_SDK_PATH etc. confirms that a CMakeLists.txt + C++ source file that won't build with the latest SDK does indeed build just fine with the old SDK.

I've attempted to compare the two build/Makefile versions and they are very different.

Further update

A GitHub issue has already been raised regarding this error. I've added a minimal example demonstrating the problem there.

  • Updated the question with the template code
    – Chris
    Nov 27, 2021 at 21:37

1 Answer 1


This is down to an issue exhibited by the 1.3.0 Pico SDK version when used on Raspberry Pi OS "Buster" (and other Debian 10 distros)

It's expected to be addressed by 1.3.1

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.