0
votes

I'm writing a kernel module and I've begun to look into sockets. I've been able to include other linux headers, use their functions, and the makefile will be fine. When I include linux/socket.h, the compiler is able to find the file, but if I call socket() or connect() or such, it says they are implicitly declared. How would I be able to fix this?

I've used cat to look into the file to make sure it's correct, which it is. I've tried just hardcoding the location

/usr/src/linux-headers-4.18.0-17-generic/linux/socket.h

I've also tried using linux-headers-4.18.0-17's socket.h but that also doesn't work.

one of the errors: error: implicit declaration of function 'socket'; did you mean 'sget'? [-Werror=implicit-function--declaration]

1

1 Answers

0
votes

Because it's not socket(), it's sys_socket() and you also need the header file containing the system calls. That one only contains structs and constants. The header file with the function itself is linux/syscalls.h.