ESP32 + Eclipse - How can I add components to Include Dirs?

fermienrico
Posts: 11
Joined: Sat Oct 14, 2017 6:31 am

ESP32 + Eclipse - How can I add components to Include Dirs?

Postby fermienrico » Thu Nov 02, 2017 2:49 am

Hi all,

I followed Neil's tutorial here:

https://www.youtube.com/watch?v=bYh2w0HzS7s

I've got everything working except for a library that I added in components folder (U8g2). U8g2 library has two source folders, so I made a component.mk file in project-folder/components/U8g2/ with the following:

Code: Select all

COMPONENT_SRCDIRS := src src/clib
COMPONENT_ADD_INCLUDEDIRS := src src/clib
OK. make all and I can compile everything sweet! I got my LCD working through command line "make flash".

Now, back to Eclipse. It cannot find a lot of the U8g2 class instances and it gives me a bunch of swiggly red lines calling "..... cannot be resolved".

Image

My includes and everything look solid in the project settings. Not sure what's wrong!
Image

I think I am about to go punch a hole in the wall. Eclipse has the worst piece of software indexer - It is a seperate piece of crap that works on its own mind. Compilation succeeds but indexing doesn't. It is like rolling a dice with the indexer. Half the time it does some magic and half of the time it works.

chegewara
Posts: 2378
Joined: Wed Jun 14, 2017 9:00 pm

Re: ESP32 + Eclipse - How can I add components to Include Dirs?

Postby chegewara » Thu Nov 02, 2017 6:18 am

Sometimes its autoindexing when you just make with eclipse and when you pass thru make with no errors then all red lines gone. Sometimes you will have to add some includes even if you can compile with no problem from cli eclipse wont let you to compile. But with extra includes it works.

fermienrico
Posts: 11
Joined: Sat Oct 14, 2017 6:31 am

Re: ESP32 + Eclipse - How can I add components to Include Dirs?

Postby fermienrico » Fri Nov 03, 2017 5:40 am

Can you tell me what exactly I need to add in the includes?

My project structure is as follows:

Code: Select all

myapp/
	myapp.cpp
	components/
		U8g2/
			src/
				clib/
and my components.mk file is described in the first post.

I have tried adding a local workspace path:

Code: Select all

/myapp/components/U8g2
/myapp/components/U8g2/src
/myapp/components/U8g2/src/clib
/myapp/build/include
/myapp/build/U8g2
but none of those work!

chegewara
Posts: 2378
Joined: Wed Jun 14, 2017 9:00 pm

Re: ESP32 + Eclipse - How can I add components to Include Dirs?

Postby chegewara » Fri Nov 03, 2017 6:37 am

I dont meant to add includes to eclipse settings. I mean to add

Code: Select all

#include some_header.h
directives in files you cant compile. This example is just to show many cases i have:
many and really many times i have this red line ie underlying uint8_t, uint16_t etc. Maybe its wrong prepared eclipse environment but it suits to me how it is. Those files are easy compiled from command line, but to get rid of it i just need to add

Code: Select all

#include "freertos/FreeRTOS.h"
. No more problems with indexing.
In your case it will be some header file from U8g2 library.

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

Re: ESP32 + Eclipse - How can I add components to Include Dirs?

Postby kolban » Sat Nov 04, 2017 5:05 am

What I have found useful is to see an error of the form

MyType myVar;

where MyType can't be found and then search through the source and header files to find where MyType is in fact defined. From there, it should be procedural to add the relevant include into Eclipse and then manually re-build the index (at least that has worked for me so far).

If there are still problems and mysteries. I'll be happy to try and assist.
Free book on ESP32 available here: https://leanpub.com/kolban-ESP32

fermienrico
Posts: 11
Joined: Sat Oct 14, 2017 6:31 am

Re: ESP32 + Eclipse - How can I add components to Include Dirs?

Postby fermienrico » Sat Nov 04, 2017 3:06 pm

Thanks Neil.

When you say "add includes", does that mean add "#include file.h" on my main.cpp or add includes in the Paths/Includes settings of the project in Eclipse IDE?

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

Re: ESP32 + Eclipse - How can I add components to Include Dirs?

Postby kolban » Sat Nov 04, 2017 10:41 pm

To start answering the last question ... maybe both.

For example, if your code contains:

MyType myVar;

Then the compiler will expect to "know" what MyType looks like. If it isn't defined in the C/C++ file that uses it, then it will have to be defined in one of the header files that your source file includes. That can be either explicitly by a direct #include or implicitly by a #include of a header that itself includes your type definition. Once done, you should be able to run "make" at your Linux command line.

For our story regarding Eclipse, understand that Eclipse is the editor environment your are likely using but it is still the ESP-IDF build system you are using to compile. The only reason you have to add directories which host include files into your Eclipse project is to remove "not found" messages in your editor. Since the compilation is performed by ESP-IDF build, editor validation errors shown in Eclipse are actually harmless. You would fix these by adding paths to include directories only to give you better entry assistance and cleanup the editor environment.
Free book on ESP32 available here: https://leanpub.com/kolban-ESP32

Who is online

Users browsing this forum: No registered users and 59 guests