You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi, I write a C program which will send an HTTP request to a server and it can run successfully when compiling it to machine code.
When I try to use wasi-sdk to compile it, I encounter the following errors. It seems that wasi-sdk cannot find the socket library API. What should I do to compile it successfully? Thank you very much!
ubuntu:~/c-app$ /home/ubuntu/wasi-sdk-23.0/bin/clang --sysroot=/home/ubuntu/wasi-sdk-23.0/share/wasi-sysroot app.c -o app.wasm
app.c:24:9: error: call to undeclared function'socket'; ISO C99 and later do not support implicit functiondeclarations [-Wimplicit-function-declaration]
24 | sock = socket(PF_INET, SOCK_STREAM, IPPROTO_TCP);| ^
app.c:25:2: error: call to undeclared function'setsockopt'; ISO C99 and later do not support implicit functiondeclarations [-Wimplicit-function-declaration]
25 | setsockopt(sock, IPPROTO_TCP, TCP_NODELAY, (const char *)&on, sizeof(int));| ^
app.c:25:2: note: did you mean 'getsockopt'?
/home/ubuntu/wasi-sdk-23.0/share/wasi-sysroot/include/wasm32-wasi/sys/socket.h:436:5: note: 'getsockopt' declared here
436 | int getsockopt (int, int, int, void *__restrict, socklen_t *__restrict);| ^
app.c:32:5: error: call to undeclared function'connect'; ISO C99 and later do not support implicit functiondeclarations [-Wimplicit-function-declaration]
32 | if(connect(sock, (struct sockaddr *)&addr, sizeof(struct sockaddr_in)) == -1){
| ^
3 errors generated.
Hi, I write a C program which will send an HTTP request to a server and it can run successfully when compiling it to machine code.
When I try to use
wasi-sdk
to compile it, I encounter the following errors. It seems thatwasi-sdk
cannot find the socket library API. What should I do to compile it successfully? Thank you very much!The text was updated successfully, but these errors were encountered: