ESP32 Eclipse custom library include path

etsura
Posts: 2
Joined: Fri Apr 27, 2018 7:06 pm

ESP32 Eclipse custom library include path

Postby etsura » Fri Apr 27, 2018 7:17 pm

Hi everyone! Can anybody help me with include path in eclipse ide with esp32 dev tools?
I developed a library to use with cc2530znp (i want to make a zigbee-to-internet gateway) and i tried to add src directory path of my library to my esp32 project "Properties -> C/C++ General -> Path and symbols -> Includes" to all languages and all configurations but rebuild project issue an error - fatal error: znp.h: No such file or directory. Actualy i tried to add sources path to "Preprocessor include" into "CDT User setting entries" but there is no effect, build was not success ((

User avatar
kolban
Posts: 1683
Joined: Mon Nov 16, 2015 4:43 pm
Location: Texas, USA

Re: ESP32 Eclipse custom library include path

Postby kolban » Mon Apr 30, 2018 3:59 am

Howdy and welcome to the community.

Getting paths just right in Eclipse can be complex but ultimately rewarding. Experience has show us that for best results, a complete description of all your settings, an example of the error produced and the actual locations of the files on your file system of any files that are claimed not to be found or referenced does help. While this may take you a little bit more time to describe, the ends results are far more likely to result in a faster resolution.
Free book on ESP32 available here: https://leanpub.com/kolban-ESP32


mkseven32
Posts: 32
Joined: Mon Apr 23, 2018 1:21 am

Re: ESP32 Eclipse custom library include path

Postby mkseven32 » Wed May 02, 2018 7:35 am

kolban wrote:Howdy and welcome to the community.

Getting paths just right in Eclipse can be complex but ultimately rewarding. Experience has show us that for best results, a complete description of all your settings, an example of the error produced and the actual locations of the files on your file system of any files that are claimed not to be found or referenced does help. While this may take you a little bit more time to describe, the ends results are far more likely to result in a faster resolution.

so everytime when we include a file in the project , we also need to add the PATH in the eclipse option setting ?

anyway , why i have add all path , there is also a error happen====> Symbol 'TOUCH_PAD_NUM9' could not be resolved
Attachments
qq.png
qq.png (37.54 KiB) Viewed 11683 times

User avatar
kolban
Posts: 1683
Joined: Mon Nov 16, 2015 4:43 pm
Location: Texas, USA

Re: ESP32 Eclipse custom library include path

Postby kolban » Wed May 02, 2018 1:57 pm

The C programming languages allows header files to be scattered all over your file system. C doesn't constrain you to have header files in some magic and exclusive directory. With that in mind, you could create a header file in /a/b/c/d/myheader.h.

When you execute a:

#include "myheader.h"

you have to instruct the C compiler where to go look to resolve/locate header files. You do this with the compile "-I <path>" flag where you can add as many include directories as you like.

Now, put the compiler to one side and think of a smart C editor. The C editor tries to make warn you if you use symbols that aren't defined. Since symbols can be defined in header files, it now means that the C editor ALSO has to know where to go and look for header files. If you now include a header file in your application that exists in a directory that you haven't previously told the editor to go and look in ... then the answer to your question is "Yes" ... every time you include a new header file that is in a new directory then yes ... you must tell the editor about that new directory.

When you declare a new header directory to your editor .. you will likely be asked if you wish to "re-index" OR you may actually have to explicitly re-index. Let me try and explain that. In order for the C compiler to offer you assistance, it can't afford to go an examine the content of every header file every time you start editing C. That would be far too expensive. The thinking is that the majority of header files are "relatively" static. Meaning that they are "just there" and you are not "likely" to edit them. To improve performance, smart editors will perform a one time indexing of all their content and keep the resulting index (cache) around so that a search can be performed dramatically faster than having to scour all the files every time. When you add a new directory to your list of directories to be searched and you are finding that the content of a header in that directory is not being found, consider re-running the index for your editor.
Free book on ESP32 available here: https://leanpub.com/kolban-ESP32

mkseven32
Posts: 32
Joined: Mon Apr 23, 2018 1:21 am

Re: ESP32 Eclipse custom library include path

Postby mkseven32 » Thu May 03, 2018 2:17 am

excellent answer!!!
thank you very much!

when after execute Project -> C/C++ Index -> Rebuild , That is OK.

========vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv=============================
but there is also a question , this project was imported from the esp-idf packect which is without any changed.

there is not include the "Touch_pad.h" file in the main.c at first,
and always when i use mingw32.exe which in the toolchain to run “make” command, it is OK(i mean there is nothing error about TOUCH_PAD_NUM9 without define or declare)。 that is amazing ,how does the complier could found the symbol which header file was not included in the c file。

User avatar
kolban
Posts: 1683
Joined: Mon Nov 16, 2015 4:43 pm
Location: Texas, USA

Re: ESP32 Eclipse custom library include path

Postby kolban » Thu May 03, 2018 4:55 pm

When you enter "make", you are using the "Makefile" (the control file that governs make's operation) that is supplied by Espressif in their ESP-IDF. That Makefile has logic in it to search within the ESP-IDF directory and include folders for components automatically. The build system supplied by ESP-IDF is there to make life simpler. It already knows how to include directories for compilation. Your usage of a smart editor doesn't know anything out Espressif's build system and hence you have to explicitly configure it with knowledge about the directories which contain your headers.
Free book on ESP32 available here: https://leanpub.com/kolban-ESP32

Who is online

Users browsing this forum: No registered users and 337 guests