Page 1 of 1

Eclipse (Windows) does not find headers in components

Posted: Tue Aug 22, 2017 9:13 am
by Koschi
After setting up the project in eclipse following the instructions for windows machines and makeing it one time to let eclipse collect the header files paths everything works fine for the main.c file.
Then i added a component and included the "esp_log.h" in the components .cpp (yes, the component is written in C++) as well, assuming there should be no problem, since eclipse should already know about this file. It seems it doesn't. The file is marked as unknown and functions defined in it are marked as undefined. Building the project however works without a problem.
I would like to fix this because not having auto-completion and having false errors is really annoying.

The include part of main.c:

Code: Select all

#include <stdio.h>
#include <string.h>
#include "freertos/FreeRTOS.h"
#include "esp_wifi.h"
#include "esp_system.h"
#include "esp_event.h"
#include "esp_event_loop.h"
#include "esp_log.h"
#include "nvs_flash.h"
#include "driver/gpio.h"
#include "driver/uart.h"
#include "soc/uart_struct.h"

#include "../components/mylogger/mylogger.h"
The include part of mylogger.cpp

Code: Select all

#include <cstdio>
#include "FunshineLog.h"
#include "esp_log.h"
In main.c everything is correct. In mylogger.cpp the line #include "esp_log.h" is marked as "unresolved inclusion" and functions defined in it (e.g. esp_log_set_vprintf()) are, naturally, marked as "undefined".

This presists even after cleaning and then building the project again.

Is there a way to fix this? Even manually would be okay for now.

Re: Eclipse (Windows) does not find headers in components

Posted: Tue Aug 22, 2017 10:09 pm
by kolban
Here is the recipe I use for clean builds and editing in an Eclipse environment for C++ with ESP32.

https://www.youtube.com/watch?v=-ttiPfmrehU

Re: Eclipse (Windows) does not find headers in components

Posted: Tue Aug 22, 2017 11:31 pm
by ESP_Angus
Koschi wrote: Then i added a component and included the "esp_log.h" in the components .cpp (yes, the component is written in C++) as well, assuming there should be no problem, since eclipse should already know about this file. It seems it doesn't. The file is marked as unknown and functions defined in it are marked as undefined. Building the project however works without a problem.
In our recommended configuration[*], Eclipse needs to parse the build output in order to determine the list of include paths for headers (in Eclipse-speak, this is called the "C/C++ Index". If this parsing doesn't happen correctly, these kind of problems occur (headers and symbols are marked as unknown in the editor, even though the project builds correctly).

The most likely root cause is that one of the Project Properties settings listed in the setup guide is missing or has a typo in it:
http://esp-idf.readthedocs.io/en/latest ... properties

We know this is fiddly to get right, and we're looking into ways to make it more streamlined.

To help debug the process further, the menu items under Project -> C/C++ Index can be useful. These let you rebuild the index for a given file, or create a "Parser Log File" which shows the information that the parser was able to pull from the build process for that file.
kolban wrote:Here is the recipe I use for clean builds and editing in an Eclipse environment for C++ with ESP32.
[*] Kolban's approach as shown in the video here will also work, but it's different to the recommended approach in the docs because it involves manually listing all the include directory paths and then keeping them up to date if/when they change. The Index parsing approach that we recommend does this automatically - that process is more "magic" and can be harder to debug but it leads to less hassle in the long run. It's up to you how you want do it.

Re: Eclipse (Windows) does not find headers in components

Posted: Thu Aug 24, 2017 8:46 am
by Koschi
Thanks a lot for your suggestions, but sadly this didn't solve my problem. I double checked the projects configuration again, and it is configured exactly as described in the documentation (http://esp-idf.readthedocs.io/en/latest ... dows-setup). Also in "main.c" the header files are known by eclipse. It's just inside the components eclipse doesn't know the exact same header file.

As example i have two screenshots of eclipse's code view. The first from the main.c file:
Image

The second one is from the same project of the file "components/configstore/configstore.h":
Image

As you can see eclipse knows where to look for esp_log.h inside main.c, but it doesn't know it inside configstore.h.

I was also not able to resolve this with the commands under "Project -> C/C++ Index". Rebuilding the index, rebuilding the project, cleaning it, nothing works. It always comes back to this. Everything's okay inside main.c, but inside the components (.h as well as .cpp files) it does not work.

This of course does not affect the building process. This works fine.

@kolban: I haven't tried your solution for now, since i would prefer an automated version, even if it takes more time to set up. But i will try this next and see if it makes a difference.

Re: Eclipse (Windows) does not find headers in components

Posted: Thu Aug 24, 2017 12:41 pm
by ESP_krzychb
Koschi wrote: As example i have two screenshots of eclipse's code view. The first from the main.c file:
Image

The second one is from the same project of the file "components/configstore/configstore.h":
Image
Something got broken. I do not see the images.

Re: Eclipse (Windows) does not find headers in components

Posted: Thu Aug 24, 2017 1:01 pm
by Koschi
Sorry, it seems i messed up linking to the images.
Here they are again, hopefully correct this time.

The first from the main.c file:
header-files-main.png
header-files-main.png (3.95 KiB) Viewed 20266 times
The second one is from the same project of the file "components/configstore/configstore.h":
header-files-configstore.png
header-files-configstore.png (8.89 KiB) Viewed 20266 times

Re: Eclipse (Windows) does not find headers in components

Posted: Fri Aug 25, 2017 12:20 pm
by Koschi
After following @kolban's instructions and adapting the include path XML file for windows / current eclipse version everything works! :D

I used my original eclipse project that i set up using espressifs documentation. Then i included the include paths as described by@kolban. This didn't work out of the box since the XML format seems to have changed a bit. I adapted this and also added the /build/include path of the project to correctly have the config macros resolved and now everything works like a charme.

Find attached the slightly adapted XML file for include import. This should also work on linux and mac, but i couldn't test it.

I am using one additional path variable (${MSYS32_ROOT}) which points to the root directory of the MSYS32 environment in windows. If you followed the instructions in the official documentation this should be "C:/msys32". On linux and macos one would have to set it accordingly.

Although i still would prefer a more automated version (the XML file will have to be adapted everytime the SDK changes), this seems to be the most convenient version right now.

@kolban: If you like you may of course use my XML file for your repository. I'll hopefully set up a small how-to in my own blog sometime soon.


Thanks for helping me!

Re: Eclipse (Windows) does not find headers in components

Posted: Fri Aug 25, 2017 1:18 pm
by enitalp
I stopped working with eclipse because of that. and even settings the path in the properties, i regularly lost them for no reason.

Switched to visual studio code with a config file for esp-idf.
It gave me the support of source control (Perforce) and correct parsing of include file recursivly in sub folder.

I still find the autocomplete and some syntaxe coloring very dodgy, will have to dig more in it.

Re: Eclipse (Windows) does not find headers in components

Posted: Sat Aug 26, 2017 5:59 am
by EmperorRXF
enitalp wrote:I stopped working with eclipse because of that. and even settings the path in the properties, i regularly lost them for no reason.

Switched to visual studio code with a config file for esp-idf.
It gave me the support of source control (Perforce) and correct parsing of include file recursivly in sub folder.

I still find the autocomplete and some syntaxe coloring very dodgy, will have to dig more in it.
I'm too trying to get away from eclipse, would like to know what steps I need to follow to make the switch into VS Code if you could be so kind?

Re: Eclipse (Windows) does not find headers in components

Posted: Mon Aug 28, 2017 1:32 pm
by enitalp
EmperorRXF wrote:
enitalp wrote:I stopped working with eclipse because of that. and even settings the path in the properties, i regularly lost them for no reason.

Switched to visual studio code with a config file for esp-idf.
It gave me the support of source control (Perforce) and correct parsing of include file recursivly in sub folder.

I still find the autocomplete and some syntaxe coloring very dodgy, will have to dig more in it.
I'm too trying to get away from eclipse, would like to know what steps I need to follow to make the switch into VS Code if you could be so kind?
viewtopic.php?f=2&t=2818