Page 1 of 1

Anyone used ioctl?

Posted: Fri Jun 08, 2018 4:18 pm
by fly135
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

Re: Anyone used ioctl?

Posted: Fri Jun 08, 2018 4:47 pm
by kolban
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

Re: Anyone used ioctl?

Posted: Fri Jun 08, 2018 5:48 pm
by fly135
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

Re: Anyone used ioctl?

Posted: Sat Jun 09, 2018 1:40 pm
by ESP_igrr
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.

Re: Anyone used ioctl?

Posted: Sat Jun 09, 2018 3:07 pm
by fly135
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