Hi Everyone, this might be very silly question but I still couldn't be able to overcome this. I am currently working on a product which needs to use a few sensors and transact some data using MQTT and have to use ESP-IDF.
So I just created a sample project in VSCode and created a component library just using "idf.py -C components create-component my_component" command and I just added "my_component.h" in a "main.c" file and try to build but ended up "fatal error: my_component.h: No such file or directory" although all CMakeLists and make file are included.
- sample_project/
- CMakeLists.txt
- sdkconfig
- components/ - my_component/
- CMakeLists.txt
- my_component.c
- include/
- my_component.h
- main/ - CMakeLists.txt
- main.c
- component.mk
- build/
Please let me know if you need to clarify more things about the questions.
Apology for my poor writing skill and thanks so much in advance for your help.
project main file cannot find the component header file ESP32 ESP-IDF VSCode
-
- Posts: 11
- Joined: Sun Sep 06, 2020 6:46 am
-
- Posts: 3
- Joined: Fri Nov 19, 2021 2:59 am
Re: project main file cannot find the component header file ESP32 ESP-IDF VSCode
In - main/ - CMakeLists.txt you should have something like the following :
or
Code: Select all
idf_component_register(SRCS "main.c"
INCLUDE_DIRS "."
PRIV_REQUIRES my_component)
Code: Select all
set(includedirs
../components/my_component/include/
"." # this line is probably not needed since main dir is included by default and there are no sub-directories under main
)
idf_component_register(SRCS "main.c"
INCLUDE_DIRS ${includedirs}
PRIV_REQUIRES my_component)
-
- Posts: 11
- Joined: Sun Sep 06, 2020 6:46 am
Re: project main file cannot find the component header file ESP32 ESP-IDF VSCode
Hi @troyduncan, noted and thanks so much for your reply. It worked and thanks so much again for your prompt response...
-
- Posts: 2
- Joined: Wed Sep 04, 2024 3:21 am
Re: project main file cannot find the component header file ESP32 ESP-IDF VSCode
hello everyone , i have follow before recommands to install c/c++ extensions and build the project,the include problem have been sloved successfully,however i face another cmake warning .
in c_cpp_properties.json :
Cannot find "${env:IDF_PATH}/components/"
and cmake error in CMakeList.txts:
[{
"resource": "/E:/esp32/esp32-c3-jlc/project/humi_temp/CMakeLists.txt",
"owner": "cmake-configure-diags",
"severity": 8,
"message": "CMake Error at CMakeLists.txt:7 (include):include could not find requested file:\n\n /tools/cmake/project.cmake",
"source": "CMake (include)",
"startLineNumber": 7,
"startColumn": 1,
"endLineNumber": 7,
"endColumn": 10000
}]
blow is my c_cpp_properties.json:
{
"configurations": [
{
"name": "ESP-IDF",
"compilerPath": "${config:idf.toolsPathWin}\\tools\\riscv32-esp-elf\\esp-13.2.0_20230928\\riscv32-esp-elf\\bin\\riscv32-esp-elf-gcc.exe",
"compileCommands": "${config:idf.buildPath}/compile_commands.json",
"includePath": [
"${config:idf.espIdfPath}/components/**",
"${config:idf.espIdfPathWin}/components/**",
"${workspaceFolder}/**"
],
"browse": {
"path": [
"${config:idf.espIdfPath}/components",
"${config:idf.espIdfPathWin}/components",
"${workspaceFolder}"
],
"limitSymbolsToIncludedHeaders": true
}
}
],
"version": 4
}
CMakeLists.txt:
# For more information about build system see
# https://docs.espressif.com/projects/esp ... ystem.html
# The following five lines of boilerplate have to be in your project's
# CMakeLists in this exact order for cmake to work correctly
cmake_minimum_required(VERSION 3.16)
include($ENV{IDF_PATH}/tools/cmake/project.cmake)
project(humi_temp)
attach is my extension version info:
my c/c++ extension version:v1.21.6
in c_cpp_properties.json :
Cannot find "${env:IDF_PATH}/components/"
and cmake error in CMakeList.txts:
[{
"resource": "/E:/esp32/esp32-c3-jlc/project/humi_temp/CMakeLists.txt",
"owner": "cmake-configure-diags",
"severity": 8,
"message": "CMake Error at CMakeLists.txt:7 (include):include could not find requested file:\n\n /tools/cmake/project.cmake",
"source": "CMake (include)",
"startLineNumber": 7,
"startColumn": 1,
"endLineNumber": 7,
"endColumn": 10000
}]
blow is my c_cpp_properties.json:
{
"configurations": [
{
"name": "ESP-IDF",
"compilerPath": "${config:idf.toolsPathWin}\\tools\\riscv32-esp-elf\\esp-13.2.0_20230928\\riscv32-esp-elf\\bin\\riscv32-esp-elf-gcc.exe",
"compileCommands": "${config:idf.buildPath}/compile_commands.json",
"includePath": [
"${config:idf.espIdfPath}/components/**",
"${config:idf.espIdfPathWin}/components/**",
"${workspaceFolder}/**"
],
"browse": {
"path": [
"${config:idf.espIdfPath}/components",
"${config:idf.espIdfPathWin}/components",
"${workspaceFolder}"
],
"limitSymbolsToIncludedHeaders": true
}
}
],
"version": 4
}
CMakeLists.txt:
# For more information about build system see
# https://docs.espressif.com/projects/esp ... ystem.html
# The following five lines of boilerplate have to be in your project's
# CMakeLists in this exact order for cmake to work correctly
cmake_minimum_required(VERSION 3.16)
include($ENV{IDF_PATH}/tools/cmake/project.cmake)
project(humi_temp)
attach is my extension version info:
my c/c++ extension version:v1.21.6
- Attachments
-
- Snipaste_2024-09-04_11-24-31.png (30.02 KiB) Viewed 1516 times
Who is online
Users browsing this forum: Gaston1980, Larry Cruxton and 112 guests