I was trying to link uWebSocket in MacOs Xcode due to this guide https://medium.com/@tabvn/c-how-to-linking-uwebsocket-in-macos-xcode-9-ef3ffea880e4 but, when I tried to install uWebSocket, I got error EpollEvent.h not found! Can anybody help me with this?
How to fix "fatal error: 'sys/epoll.h' file not found" in OSX?
Asked Answered
You're right, it can be a bit tricky to compile uWebSockets. After some playing around I found out you need to use libuv instead of epoll, as epoll is part of the Linux kernel and is unavailable on MacOs.
Install with homebrew:
brew install libuv
optionally install openssl and zlib (the makefile below assumes they are installed)
brew install openssl zlib
Change the Makefile to
.PHONY: examples
examples:
# HelloWorld
clang -DLIBUS_USE_LIBUV -DLIBUS_USE_OPENSSL -flto -O3 -c -IuSockets/src uSockets/src/*.c uSockets/src/eventing/*.c
clang++ -flto -O3 -c -std=c++17 -Isrc -IuSockets/src examples/HelloWorld.cpp
clang++ -L/usr/local/lib -luv -lssl -lcrypto -lz -flto -O3 -s *.o -o HelloWorld
rm *.o
# HelloWorldThreaded
clang -DLIBUS_USE_LIBUV -DLIBUS_USE_OPENSSL -flto -O3 -c -IuSockets/src uSockets/src/*.c uSockets/src/eventing/*.c
clang++ -flto -O3 -c -std=c++17 -Isrc -IuSockets/src examples/HelloWorldThreaded.cpp
clang++ -L/usr/local/lib -luv -lssl -lcrypto -lz -lpthread -flto -O3 -s *.o -o HelloWorldThreaded
rm *.o
# EchoServer
clang -DLIBUS_USE_LIBUV -DLIBUS_USE_OPENSSL -flto -O3 -c -IuSockets/src uSockets/src/*.c uSockets/src/eventing/*.c
clang++ -flto -O3 -c -std=c++17 -Isrc -IuSockets/src examples/EchoServer.cpp
clang++ -L/usr/local/lib -luv -lssl -lcrypto -lz -flto -O3 -s *.o -o EchoServer
rm *.o
# EchoServerThreaded
clang -DLIBUS_USE_LIBUV -DLIBUS_USE_OPENSSL -flto -O3 -c -IuSockets/src uSockets/src/*.c uSockets/src/eventing/*.c
clang++ -flto -O3 -c -std=c++17 -Isrc -IuSockets/src examples/EchoServerThreaded.cpp
clang++ -L/usr/local/lib -luv -lssl -lcrypto -lz -lpthread -flto -O3 -s *.o -o EchoServerThreaded
rm *.o
and run make
the macOS don't support epoll, you should develop an unix environment if you want to use epoll.
© 2022 - 2024 — McMap. All rights reserved.
epoll
is a Linux thing. Which header are you getting an error about? sys/epoll.h or EpollEvent.h? – Unmovedconfigure
orcmake
or something else; check the docs) that tests for the presence of headers and functions and enables or disables their use accordingly. – Unmoved