application code can't find errno

User avatar
mzimmers
Posts: 643
Joined: Wed Mar 07, 2018 11:54 pm
Location: USA

application code can't find errno

Postby mzimmers » Mon Sep 20, 2021 4:21 pm

Hi all -

I ran into a similar problem a few years ago, but it's reappeared.

I'm trying to use errno in my app, but it's coming up undefined. I also notice that I'm getting a lot of errors in this file:
~/.espressif/tools/xtensa-esp32-elf/esp-2021r1-8.4.0/xtensa-esp32-elf/xtensa-esp32-elf/include/c++/8.4.0/xtensa-esp32-elf/no-rtti/bits/error_constants.h

regarding the various error constants (eg EAFNOSUPPORT) being undefined.

Did I find my way to the wrong include path(s)? This is the relevant portion of my CMakeLists.txt file:

Code: Select all

INCLUDE_DIRS 
"."
"${IDF_PATH}/components" 
"${IDF_PATH}/components/driver/include/driver"
"${IDF_PATH}/components/esp_wifi/include"
"${IDF_PATH}/components/freertos/include/freertos"
"${IDF_PATH}/components/hal/include/hal"
"${IDF_PATH}/components/lwip/"
"${IDF_PATH}/components/lwip/lwip/src/include/lwip"
"${IDF_PATH}/components/mbedtls/esp_crt_bundle/include/"


Thanks for any ideas...

EDIT: when I try to follow errno in the IDE, I get to this file:

.espressif/tools/xtensa-esp32-elf/esp-2021r1-8.4.0/xtensa-esp32-elf/xtensa-esp32-elf/include/c++/8.4.0/cerrno

Am I having this problem because I'm not correctly handling the mix of C and C++ files in my application?

Any help would be GREATLY appreciated.

EDIT 2: after some experimenting, I've reduced the errors to one file:

~/.espressif/tools/xtensa-esp32-elf/esp-2021r1-8.4.0/xtensa-esp32-elf/xtensa-esp32-elf/include/c++/8.4.0/ext/string_conversions.h

Am I even supposed to be using this file? I have no references to directories within the toolchain in my configuration file.

User avatar
mbratch
Posts: 298
Joined: Fri Jun 11, 2021 1:51 pm

Re: application code can't find errno

Postby mbratch » Tue Sep 21, 2021 10:35 am

What do you mean by "application code can't find errno"? Is it a compile error or a linker error? A compiler error would indicate missing the appropriate header file. A linker error would indicate not linking with the appropriate library. Exactly what is the error message?

User avatar
mzimmers
Posts: 643
Joined: Wed Mar 07, 2018 11:54 pm
Location: USA

Re: application code can't find errno

Postby mzimmers » Tue Sep 21, 2021 2:07 pm

Hi mbratch -

They're compiler errors:

Code: Select all

{
	"resource": "/home/mzimmers/.espressif/tools/xtensa-esp32-elf/esp-2021r1-8.4.0/xtensa-esp32-elf/xtensa-esp32-elf/include/c++/8.4.0/ext/string_conversions.h",
	"owner": "cpp",
	"severity": 8,
	"message": "'errno' was not declared in this scope",
	"startLineNumber": 84,
	"startColumn": 16,
	"endLineNumber": 84,
	"endColumn": 16
}
But given where this file is, it seems doubtful that it's missing a header. I'm thinking something is incorrect with my configuration, though I don't know where to look.

boarchuz
Posts: 559
Joined: Tue Aug 21, 2018 5:28 am

Re: application code can't find errno

Postby boarchuz » Tue Sep 21, 2021 2:19 pm

That's not the purpose of INCLUDE_DIRS. Have a look through some IDF components and get a feel for some typical CMakeLists.

User avatar
mzimmers
Posts: 643
Joined: Wed Mar 07, 2018 11:54 pm
Location: USA

Re: application code can't find errno

Postby mzimmers » Tue Sep 21, 2021 2:45 pm

Hi boarchuz - I've looked at some CMakeLists.txt files, and I see what you mean - none reference the IDF. So, a couple questions:

1. should I not even reference the top-level directory (${IDF_PATH}/components) in my INCLUDE_DIRS section?
2. what/where is the appropriate method for telling cmake where to look for component files?

Thank you...this is very helpful.

boarchuz
Posts: 559
Joined: Tue Aug 21, 2018 5:28 am

Re: application code can't find errno

Postby boarchuz » Tue Sep 21, 2021 3:00 pm

1. Correct.
2. Add other components it depends on to REQUIRES: https://docs.espressif.com/projects/esp ... quirements

User avatar
mzimmers
Posts: 643
Joined: Wed Mar 07, 2018 11:54 pm
Location: USA

Re: application code can't find errno

Postby mzimmers » Tue Sep 21, 2021 3:54 pm

Hi boarchuz -

OK, this is helpful. I've added some components using the REQUIRED keyword, and that has eliminated most compile-time errors. I'm still having trouble with a few:

Code: Select all

#include "freertos/port/xtensa/include/freertos/portmacro.h"
#include "freertos/include/freertos/semphr.h"
#include "lwip/lwip/src/include/lwip/ip_addr.h"
I've added freertos and lwip in the REQUIRES statement. Why is the compiler not finding these files?

Thanks...

boarchuz
Posts: 559
Joined: Tue Aug 21, 2018 5:28 am

Re: application code can't find errno

Postby boarchuz » Tue Sep 21, 2021 4:19 pm

Because those headers have been added to the include path by the respective components, and because your component depends on those components, their headers can be included in your component like this:

Code: Select all

#include "freertos/FreeRTOS.h"
#include "freertos/semphr.h"
#include "lwip/ip_addr.h"

User avatar
mzimmers
Posts: 643
Joined: Wed Mar 07, 2018 11:54 pm
Location: USA

Re: application code can't find errno

Postby mzimmers » Tue Sep 21, 2021 4:56 pm

Ahhh...so, let me make sure I understand the mechanism here: once you add the components with REQUIRES, in the source code, you only have to reference the component (eg: lwip) and the build mechanism will search that entire directory structure for the relevant file?

Who is online

Users browsing this forum: Google [Bot] and 113 guests