Total Pageviews

Sunday, 1 September 2019

如何解决mac上的'sys/epoll.h' file not found的问题

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
from stackoverflow.com/questions/55591983/how-to-fix-fatal-error-sys-epoll-h-file-not-found-in-osx

No comments:

Post a Comment