Quantcast
Channel: Raspberry Pi Forums
Viewing all articles
Browse latest Browse all 7503

SDK • CMakelist configuration with Raspbery Pi Pico on VScode

$
0
0
Hello everybody,

I have coded a simple C application for a Raspberry Pi Pico on VScode using the Raspberry Pi Pico extension and I succeed to complile, build and flash the program in the target. I had only one C file.
Then, I have tried to add a custom library (raik060spilib) to the project composed by an additional header file and a source file but I always have an error when a I try to compile. I guess that it is due to a bad CMakeLists.txt configuration but I don't find how to solve it.
The error is : ../arm-none-eabi/bin/ld.exe: cannot find -lraik060spilib: No such file or directory

My file tree is as shown below :
RAIK060SPI
|--- .vscode
|--- build
|--- .gitignore
|--- CMakeLists.txt
|--- pico_sdk_import.cmake
|--- raik060spicom.c
|--- raik060spicom.h
|--- raik060spicom.pio
|--- raik060spilib.c
|--- raik060spilib.h

My CMakeLists.txt is :

Code:

# Generated Cmake Pico project filecmake_minimum_required(VERSION 3.13)set(CMAKE_C_STANDARD 11)set(CMAKE_CXX_STANDARD 17)set(CMAKE_EXPORT_COMPILE_COMMANDS ON)# Initialise pico_sdk from installed location# (note this can come from environment, CMake cache etc)# == DO NOT EDIT THE FOLLOWING LINES for the Raspberry Pi Pico VS Code Extension to work ==if(WIN32)    set(USERHOME $ENV{USERPROFILE})else()    set(USERHOME $ENV{HOME})endif()set(sdkVersion 2.1.1)set(toolchainVersion 14_2_Rel1)set(picotoolVersion 2.1.1)set(picoVscode ${USERHOME}/.pico-sdk/cmake/pico-vscode.cmake)if (EXISTS ${picoVscode})    include(${picoVscode})endif()# ====================================================================================set(PICO_BOARD pico_w CACHE STRING "Board type")# Pull in Raspberry Pi Pico SDK (must be before project)include(pico_sdk_import.cmake)project(raik060spicom C CXX ASM)# Initialise the Raspberry Pi Pico SDKpico_sdk_init()# Add executable. Default name is the project name, version 0.1add_executable(raik060spicom    raik060spicom.c    )# Create file .h from pio filepico_generate_pio_header(raik060spicom ${CMAKE_CURRENT_LIST_DIR}/raik060spicom.pio)# pull in common dependenciestarget_link_libraries(raik060spicom pico_stdlib hardware_pio hardware_clocks raik060spilib)if (PICO_CYW43_SUPPORTED)    target_link_libraries(raik060spicom raik060spilib pico_cyw43_arch_none)endif()# create map/bin/hex file etc.pico_add_extra_outputs(raik060spicom)pico_enable_stdio_usb(raik060spicom 1)pico_enable_stdio_uart(raik060spicom 0)# add url via pico_set_program_url
I have look for solution on the web and I have found that "include_directories" or "target_include_directories" could solve the issue but I don't understand how I have to use it in my case.
Thank you in advance for your help if you can give me some tips.

Statistics: Posted by DJim53 — Sun Oct 12, 2025 8:14 pm



Viewing all articles
Browse latest Browse all 7503

Trending Articles