Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot find netdb.h when compiling ZMQ in C to wasm #421

Open
HaoxinSEU opened this issue May 20, 2024 · 0 comments
Open

Cannot find netdb.h when compiling ZMQ in C to wasm #421

HaoxinSEU opened this issue May 20, 2024 · 0 comments

Comments

@HaoxinSEU
Copy link

Hi community,

Thanks for your work on WASI SDK!

I'm developing a C plugin using ZMQ, so that the plugin can send some messages. However, when I compiled it with ./bin/wasm32-wasip2-clang and use ./bin/lld as the linker, I got the following errors:

In file included from /opt/miniz_extism/dependencies/zmq/src/ws_address.cpp:3:
In file included from /opt/miniz_extism/dependencies/zmq/src/precompiled.hpp:30:
/opt/miniz_extism/dependencies/zmq/src/../include/zmq.h:769:33: error: unknown type name 'sigset_t'
  769 |                           const sigset_t *sigmask_);
      |                                 ^
In file included from /opt/miniz_extism/dependencies/zmq/src/ws_address.cpp:8:
In file included from /opt/miniz_extism/dependencies/zmq/src/ws_address.hpp:11:
/opt/miniz_extism/dependencies/zmq/src/ip_resolver.hpp:9:10: fatal error: 'netdb.h' file not found
    9 | #include <netdb.h>
      |          ^~~~~~~~~
2 errors generated.
make[2]: *** [CMakeFiles/objects.dir/build.make:76: CMakeFiles/objects.dir/src/ws_address.cpp.o] Error 1
make[1]: *** [CMakeFiles/Makefile2:391: CMakeFiles/objects.dir/all] Error 2
make: *** [Makefile:146: all] Error 2

I'm quite confused with this error, because the header file netdb.h is there: ./share/wasi-sysroot/include/wasm32-wasip2/netdb.h.

My command to run cmake is:

cmake -D CMAKE_C_COMPILER=$(pwd)/../wasi-sdk/bin/wasm32-wasip2-clang -DCMAKE_LINKER=$(pwd)/../wasi-sdk/bin/lld ..

and the CMakeLists.txt file includes

add_compile_options(-D_WASI_EMULATED_SIGNAL)
target_link_libraries(libzmq wasi-emulated-signal)
set(CMAKE_C_FLAGS "--target=wasm32-wasip2")

Does anyone have a hint on why I got this error? Thanks a lot!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant