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

SDK • C++ : Is <chrono> / <threads> supported ?

$
0
0
I'm testing some simple C++ code on a PC with a CMakeLists.txt that supports both the PC and a Pico, selectively. That works when using other tests. I'm exploring <chrono> and for specifically the use of sleep_for(), At one point there's :

Code:

auto duration = std::chrono::duration_cast<std::chrono::microseconds>(end - start);std::cout << "Rendering took " << duration.count() << " microseconds.\n";
This works well on the PC. However when compiling for the Pico the following is seen at the linking stage, after the compilation proper was completed :

Code:

/usr/lib/gcc/arm-none-eabi/12.2.1/../../../arm-none-eabi/bin/ld: /usr/lib/gcc/arm-none-eabi/12.2.1/../../../arm-none-eabi/lib/thumb/v6-m/nofp/libstdc++.a(thread.o): in function `std::this_thread::__sleep_for(std::chrono::duration<long long, std::ratio<1ll, 1ll> >, std::chrono::duration<long long, std::ratio<1ll, 1000000000ll> >)':./build/thumb/v6-m/nofp/libstdc++/src/c++11/../../../../../../../src/libstdc++-v3/src/c++11/thread.cc:228: undefined reference to `usleep'
I wouldn't be that much surprised that C++ threads are not supported on the Pico since the SDK has sleep methods on its own. Is this case ? Should I encapsulate these into objects that are chosen (standard C++ or Pico SDK) depending on what type of target is defined in the cmake file so that I can rapidly develop on the PC while maintaining the ability to compile from time to time on the Pico ?

Thanks.

Statistics: Posted by mevla — Fri Feb 13, 2026 1:10 am



Viewing all articles
Browse latest Browse all 7995

Trending Articles