Page 1 of 1

using esp_timer_cxx.hpp

Posted: Wed Apr 27, 2022 7:03 am
by zamek42@gmail.com
Hi ALl,
I would like to create a project with cpp and I need to use timers, but I cannot use this file. My root CMakelist.txt contains this:

cmake_minimum_required(VERSION 3.5)
set(EXTRA_COMPONENT_DIRS "$ENV{IDF_PATH}/examples/cxx/experimental/experimental_cpp_component")
include($ENV{IDF_PATH}/tools/cmake/project.cmake)
project(MyTestProject)

and my main/CMakelists.txt is:

idf_component_register(SRCS
"main.cpp"
"control.cpp"
INCLUDE_DIRS "."
REQUIRES nvs_flash json pthread esp_timer driver esp_event)

in config I enabled the compiler options/Enable C++ exceptions option.

in my control.h ther is:

#include "esp_exception.hpp"
#include "esp_timer_cxx.hpp"

compiler said:
esp_exception.hpp: No such file or directory
esp_timer_cxx.hpp: No such file or directory

How can I use timers?

thx,
Zamek

Re: using esp_timer_cxx.hpp

Posted: Wed Apr 27, 2022 11:24 am
by ESP_igrr
Hi Zamek,

I think it will work if you add experimental_cpp_component to the REQUIRES list in idf_component_register.

(When you add experimental_cpp_component to EXTRA_COMPONENT_DIRS, this adds the component to the project. To let the build system know that your "main" component is using experimental_cpp_component, you need to list it in PRIV_REQUIRES or REQUIRES list)

Re: using esp_timer_cxx.hpp

Posted: Mon May 02, 2022 6:16 am
by zamek42@gmail.com
Hi ESP_igrr,

It is part of my CMakelists.txt :
set(EXTRA_COMPONENT_DIRS "$ENV{IDF_PATH}/examples/cxx/experimental/experimental_cpp_component")
but it is not enough. :(

thx
Zamek

Re: using esp_timer_cxx.hpp

Posted: Mon May 02, 2022 7:21 am
by zamek42@gmail.com
Hi All,

Finally that was the needed config line in main/CMakeLists.txt:
PRIV_REQUIRES "experimental_cpp_component"

thx
Zamek