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

General • Re: Pico2 compilation error: undefined reference to `Foo::getNum()'

$
0
0
Edit : Just noticed you are using VSC. This is from the command line but may still help.

This seems to have worked for me ...

Code:

set(PROJECT TestClasses)cmake_minimum_required(VERSION 3.12)include($ENV{PICO_SDK_PATH}/external/pico_sdk_import.cmake)project(${PROJECT} C CXX ASM)pico_sdk_init()add_executable(${PROJECT} TestClasses.cpp src/foo.cpp)# <--target_include_directories(${PROJECT} PRIVATE include)# <--target_link_libraries(${PROJECT} pico_stdlib)pico_add_extra_outputs(${PROJECT})pico_enable_stdio_usb(${PROJECT}  1)pico_enable_stdio_uart(${PROJECT} 0)
There's probably some alternative or better way to include all the files in 'src'.

Code:

pi@Pi4B:/tmp/TestClasses $ tree ..├── build├── CMakeLists.txt├── include│   └── foo.h├── src│   └── foo.cpp└── TestClasses.cpp

Code:

cd /tmp/TestClassescmake -S . -B ./buildcmake --build ./buildls -l ./build/*.uf2
Clear out the ''./build' directory and try again if you get build errors the first time.

Added a 'printf' etc to 'TestClasses.cpp', made it Run from RAM, and it seems to be working ...

Code:

pi@Pi4B:/tmp/TestClasses $ picotool load -f -x ./build/*.uf2The device was asked to reboot into BOOTSEL mode so the command can be executed.Loading into RAM:     [==============================]  100%The device was rebooted to start the application.pi@Pi4B:/tmp/TestClasses $ cat < /dev/ttyACM055^C
I am not a C++ programmer and not overly familiar with VSC so probably cannot help beyond this.

Statistics: Posted by hippy — Fri Dec 05, 2025 8:23 pm



Viewing all articles
Browse latest Browse all 8082

Trending Articles