Pico C trying to use the pico-display-2

Hi all .

I’m trying to use the pico-display-2 in a program as an external library - a small example just to understand how it works - , but when compiling, I’m getting the following error that I’m not understanding why.

When building, I get:

In file included from /Users/feiticeir0/pico/pimoroni-pico/drivers/st7789/st7789.hpp:5,
                 from /Users/feiticeir0/pico/pimoroni-pico/libraries/pico_display_2/pico_display_2.hpp:3,
                 from /Users/feiticeir0/pico/pico-mpu6050/main.c:4:
/Users/feiticeir0/pico/pimoroni-pico/drivers/st7789/../../common/pimoroni_common.hpp:3:10: fatal error: climits: No such file or directory
    3 | #include <climits>
      |          ^~~~~~~~~

I have the pico (pimoroni and pico) examples all built and I can test them.

My pico directory structure is:
pico/pico-sdk
pico/pimoroni-pico
pico/pico-mpu6050 <— The example program I’m trying to build

What could It be ? I’m using MacOS
Here’s my CMakeLists.txt:

cmake_minimum_required(VERSION 3.12)

# Change your executable name to something creative!
set(NAME pico-mpu6050) # <-- Name your project/executable here!

include(pimoroni_pico_import.cmake)
include($ENV{PICO_SDK_PATH}/pico_sdk_init.cmake)

set(CMAKE_C_STANDARD 11)
set(CMAKE_CXX_STANDARD 17)

pico_sdk_init()

project(pico-mpu6050)

add_executable(pico-mpu6050 main.c)

include (libraries/pico_display_2/pico_display_2)

target_link_libraries(pico-mpu6050 pico_stdlib hardware_i2c pico_display_2)

pico_add_extra_outputs(pico-mpu6050)

Thank you

I’ve sorted out this error - sort off - when using cpp instead of C.
If trying c++, PICO specific functions throw errors.
How can I use the pimoroni libraries using plain C ?

Well pico-display-2 is a C++ class, so the short answer is, you’re not going to be able to use it in plain C.

The underlying st7789 stuff is also wrapped up in a class, so it would be a bit of a fight to push it all into plain C (the old “I wouldn’t start from here…” problem!)

Hi @ahnlak !
Thank you for the reply.

I’ve managed to solve that problem by renaming my main.c to main.cpp and “use c++” . I have another problem now, but that’s MacOS X and homebew specific.

Best regards.

1 Like