uNetworking / uWebSockets

Simple, secure & standards compliant web server for the most demanding of applications
Apache License 2.0
17.21k stars 1.75k forks source link

libusockets.h: No such file or directory #1077

Closed bfamzz closed 4 years ago

bfamzz commented 4 years ago

I am getting the following error when compiling a c++ program with uWebSockets.

I cloned the built the program successfully (with uSockets) as shown:

 ---> Running in 478be4db24e8
Cloning into 'uWebSockets'...
Cloning into 'uSockets'...
make -C uSockets; \
for FILE in HelloWorld EchoServer BroadcastingEchoServer UpgradeSync UpgradeAsync; do g++ -flto -O3 -lpthread -Wconversion -std=c++17 -Isrc -IuSockets/src examples/$FILE.cpp -o $FILE uSockets/*.o -lz -lssl -lcrypto & done; \
for FILE in HelloWorldThreaded EchoServerThreaded; do g++ -pthread -flto -O3 -lpthread -Wconversion -std=c++17 -Isrc -IuSockets/src examples/$FILE.cpp -o $FILE uSockets/*.o -lz -lssl -lcrypto & done; \
wait
make[1]: Entering directory '/usr/src/uWebSockets/uSockets'
rm -f *.o
cc -DLIBUS_USE_OPENSSL -std=c11 -Isrc -flto -O3 -c src/*.c src/eventing/*.c src/crypto/*.c
ar rvs uSockets.a *.o
ar: creating uSockets.a
a - context.o
a - epoll_kqueue.o
a - gcd.o
a - libuv.o
a - loop.o
a - openssl.o
a - socket.o
a - wolfssl.o
make[1]: Leaving directory '/usr/src/uWebSockets/uSockets'
mkdir -p "/usr/local/include/uWebSockets/f2"
cp -r src/* "/usr/local/include/uWebSockets"
Removing intermediate container 478be4db24e8

Here is the compilation error I'm getting.

Scanning dependencies of target uWebSockets
[ 50%] Building CXX object CMakeFiles/uWebSockets.dir/main.cpp.o
In file included from /usr/local/include/uWebSockets/HttpContext.h:23,
                 from /usr/local/include/uWebSockets/App.h:24,
                 from /usr/src/uWebSockets/main.cpp:1:
/usr/local/include/uWebSockets/Loop.h:24:10: fatal error: libusockets.h: No such file or directory
   24 | #include <libusockets.h>
      |          ^~~~~~~~~~~~~~~
compilation terminated.
make[2]: *** [CMakeFiles/uWebSockets.dir/build.make:63: CMakeFiles/uWebSockets.dir/main.cpp.o] Error 1
make[1]: *** [CMakeFiles/Makefile2:73: CMakeFiles/uWebSockets.dir/all] Error 2
make: *** [Makefile:84: all] Error 2

How can I resolve this?

yesudeep commented 4 years ago

To summarize, you'd add the path to the directory that contains libusockets.h to the compiler include paths list.

I'm not familiar with Cmake but surely there must be a way to specify -I/wherever/uSockets/lives

bfamzz commented 4 years ago

Thanks. It worked.