How to fix "fatal error: 'sys/epoll.h' file not found" in OSX?
Asked Answered
O

2

5

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?

Ore answered 9/4, 2019 at 11:38 Comment(3)
epoll is a Linux thing. Which header are you getting an error about? sys/epoll.h or EpollEvent.h?Unmoved
@Unmoved I know epoll is Linux thing. I just want to know how can I install uWebSocket or some equivalent to use openssl on MacOS. The error was about sys/epoll.h header.Ore
Generally part of a libraries build process is a configuration step (either running configure or cmake or something else; check the docs) that tests for the presence of headers and functions and enables or disables their use accordingly.Unmoved
P
6

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

Papillon answered 9/5, 2019 at 10:58 Comment(0)
S
4

the macOS don't support epoll, you should develop an unix environment if you want to use epoll.

Shouldst answered 14/3, 2020 at 15:25 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.