I'm developing a program for raspberry pi pico with HAT from Ubuntu. I'm using arm-none-eabi-gcc with cmake. I want to include sys/socket.h for tcp/ip socket programming
From the command: $ echo | arm-none-eabi-gcc -v -x c -E -, I get this
/usr/lib/gcc/arm-none-eabi/6.3.1/include
/usr/lib/gcc/arm-none-eabi/6.3.1/include-fixed
/usr/lib/gcc/arm-none-eabi/6.3.1/../../../arm-none-eabi/include
Thus getting no such file or directory when I try to compile .c file with #include <sys/socket.h>
I want to include /usr/include and its subdirectories where socket.h file is included.
How can I add /usr/include when compiling. Also should I instead use newlib for the pico machine?
CodePudding user response:
- the version of arm-none-eabi-gcc is old;
- it cloud be using default path, trying to modify the path in the 'makefile':e.g.:a) <sys/socket.h> b)<linux/socket.h>
- the libs cloud be lost, trying to use 'sudo apt install' to slove.
CodePudding user response:
You cannot use the gcc-arm-none-eabi
toolchain if you want to use operating system features like sockets. That toolchain can only be used for embedded code, that runs without operating system support and therefore operating system headers are not provided. I would recommend you to compile your code with the regular gcc
installed directly on the raspberry pi and not try to cross compile. A correct cross compiling toolchain is an advanced subject and it is difficult to setup.
Edit
If you really want or need to use a cross compiler (compile on the Ubuntu machine rather than directly on the pi) you maybe find this question and its answers helpful.