using pthreads

User avatar
mzimmers
Posts: 643
Joined: Wed Mar 07, 2018 11:54 pm
Location: USA

using pthreads

Postby mzimmers » Thu Jul 09, 2020 2:30 am

Hi -

From https://docs.espressif.com/projects/esp ... hread.html:
This module offers Espressif specific extensions to the pthread library
But where is the actual pthread library itself?

Thanks.

ESP_Sprite
Posts: 9040
Joined: Thu Nov 26, 2015 4:08 am

Re: using pthreads

Postby ESP_Sprite » Thu Jul 09, 2020 8:04 am

I assume the documentation means 'the pthread api' rather than an actual library. The esp-idf functions implementing pthread functionality are here.

User avatar
mzimmers
Posts: 643
Joined: Wed Mar 07, 2018 11:54 pm
Location: USA

Re: using pthreads

Postby mzimmers » Thu Jul 09, 2020 3:41 pm

Thanks, Sprite. I'm very new to CMake, so I'm sure I'm doing something wrong, but when I include this line:

Code: Select all

find_package(Threads REQUIRED PATHS C:/esp-idf/components/pthread)
I get this error message:
CMake Error at CMakeLists.txt:148 (find_package):
Could not find a package configuration file provided by "Threads" with any
of the following names:

ThreadsConfig.cmake
threads-config.cmake
And indeed, those files don't seem to exist. Any idea what I'm doing wrong?

Thanks.

ESP_Sprite
Posts: 9040
Joined: Thu Nov 26, 2015 4:08 am

Re: using pthreads

Postby ESP_Sprite » Fri Jul 10, 2020 7:43 am

Well, it's not a package, it's a component. I'm far from an expert on CMake, but from what I understand you would add it like this:

Code: Select all

idf_component_register(...
                       REQUIRES pthread)
                       
as described here

User avatar
mzimmers
Posts: 643
Joined: Wed Mar 07, 2018 11:54 pm
Location: USA

Re: using pthreads

Postby mzimmers » Sat Jul 11, 2020 1:52 am

As I understand it, a component is an ESP-IDF concept, while a package is a CMake concept, right? So, I need some way of translating one into another.

Ideally, I could build this without having to modify the source of bctoolbox, but I don't know whether that's possible.

markkuk
Posts: 38
Joined: Wed Mar 27, 2019 11:50 am

Re: using pthreads

Postby markkuk » Sat Jul 11, 2020 6:05 am

ESP-IDF components are CMake libraries, not packages. https://docs.espressif.com/projects/esp ... components
Using pthreads should work just by including <pthread.h> in your source and calling the functions without changes in CMakeLists. At least it works like that from the main component (file containing app_main()):

User avatar
mzimmers
Posts: 643
Joined: Wed Mar 07, 2018 11:54 pm
Location: USA

Re: using pthreads

Postby mzimmers » Sat Jul 11, 2020 4:49 pm

If that's true, then the build should work as-is, right? But it's not...it's generating the error(s) I reported below.

I guess I'm missing something here.

boarchuz
Posts: 566
Joined: Tue Aug 21, 2018 5:28 am

Re: using pthreads

Postby boarchuz » Sat Jul 11, 2020 10:35 pm

What's your current CMakeLists.txt?

User avatar
mzimmers
Posts: 643
Joined: Wed Mar 07, 2018 11:54 pm
Location: USA

Re: using pthreads

Postby mzimmers » Sun Jul 12, 2020 2:39 pm

This is the file from github:

https://github.com/BelledonneCommunicat ... eLists.txt

I added this line:

Code: Select all

+include($ENV{IDF_PATH}/tools/cmake/project.cmake)
And changed this line:

Code: Select all

-find_package(Threads REQUIRED)
+find_package(Threads REQUIRED PATHS C:/esp-idf/components/pthread)
There are a few other tweaks, but I don't think they're relevant.

Thanks for looking at this.

Who is online

Users browsing this forum: Bing [Bot], selec1 and 150 guests