Anyone used ioctl?

User avatar
fly135
Posts: 606
Joined: Wed Jan 03, 2018 8:33 pm
Location: Orlando, FL

Anyone used ioctl?

Postby fly135 » Fri Jun 08, 2018 4:18 pm

I tied using ioctl on a socket in my project. It compiles, but can't find the symbol on the link. I searched the examples directory to see if any example uses ioctl, but no. So I replaced ioctl with lwip_ioctl_r and it compiles/links. Not sure if this is the right function. And not sure why ioctl isn't found.

John A

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

Re: Anyone used ioctl?

Postby kolban » Fri Jun 08, 2018 4:47 pm

Looking at the man page for ioctl() found here:

http://man7.org/linux/man-pages/man2/ioctl.2.html

It requires a #include <sys/ioctl.h>

This seems to be resolved in ESP-IDF from this file:

https://github.com/espressif/esp-idf/bl ... ys/ioctl.h
Free book on ESP32 available here: https://leanpub.com/kolban-ESP32

User avatar
fly135
Posts: 606
Joined: Wed Jan 03, 2018 8:33 pm
Location: Orlando, FL

Re: Anyone used ioctl?

Postby fly135 » Fri Jun 08, 2018 5:48 pm

Yes, I have that include, which is probably why it compiles without a complaint. Unfortunately the linker is telling me it's not in the libs.

John A

ESP_igrr
Posts: 2071
Joined: Tue Dec 01, 2015 8:37 am

Re: Anyone used ioctl?

Postby ESP_igrr » Sat Jun 09, 2018 1:40 pm

Are you including this file from a C++ source file, by chance? I see that the header file is missing exern C guards, which would cause linker issue as you describe. Try wrapping the include directive with an extern "C" block as a workaround.

User avatar
fly135
Posts: 606
Joined: Wed Jan 03, 2018 8:33 pm
Location: Orlando, FL

Re: Anyone used ioctl?

Postby fly135 » Sat Jun 09, 2018 3:07 pm

Just tried it and that didn't help. But I tried declaring the function itself as extern "C" and then it showed up as a conflicting definition in lwipopts.h, and I found another include was including that first that I should have wrapped with an extern "C". Whew! Thanks.

John A

Who is online

Users browsing this forum: No registered users and 128 guests