2

I am trying to run the websockets.c example of the libonion (https://github.com/davidmoreno/onion/tree/master/examples/websockets). However, when I run it, it gives this error.

"[ERROR codecs.c:389] Cant calculate SHA1 if gnutls is not compiled in! Aborting now"

The other examples are running fine.

I'm compiling with :

$ gcc -o muz websockets.c -I$ONION_DIR/src/ -L$ONION_DIR/src/onion/ -lonion_static -Lpam -Lgnutls -Lgcrypt -lpthread

The terminal output is given below.

[49CDC700] [2017-08-21 11:26:12] [DEBUG onion.c:216] Ignoring SIGPIPE
[49CDC700] [2017-08-21 11:26:12] [DEBUG poller.c:328] Init thread stuff for poll. Eventfd at 4
[49CDC700] [2017-08-21 11:26:12] [DEBUG poller.c:328] Init thread stuff for poll. Eventfd at 4
[49CDC700] [2017-08-21 11:26:12] [DEBUG onion.c:649] add 0x136a400 listen_point (0x136a470, 0x136a400, (nil))
[49CDC700] [2017-08-21 11:26:12] [DEBUG onion.c:461] Created default HTTP listen port
[49CDC700] [2017-08-21 11:26:12] [DEBUG listen_point.c:192] Trying to listen at (null):8080
[49CDC700] [2017-08-21 11:26:12] [DEBUG listen_point.c:233] Listening to 0.0.0.0:8080, fd 6
[49CDC700] [2017-08-21 11:26:12] [DEBUG onion.c:507] Adding listen point fd 6 to poller
[49CDC700] [2017-08-21 11:26:12] [DEBUG onion.c:515] Start polling / listening 0x136a470, 0x136a400, (nil)
[494F1700] [2017-08-21 11:26:12] [DEBUG poller.c:497] Start polling
[48CF0700] [2017-08-21 11:26:12] [DEBUG poller.c:497] Start polling
[474ED700] [2017-08-21 11:26:12] [DEBUG poller.c:497] Start polling
[47CEE700] [2017-08-21 11:26:12] [DEBUG poller.c:497] Start polling
[484EF700] [2017-08-21 11:26:12] [DEBUG poller.c:497] Start polling
[46CEC700] [2017-08-21 11:26:12] [DEBUG poller.c:497] Start polling
[49CDC700] [2017-08-21 11:26:12] [DEBUG poller.c:497] Start polling
[464EB700] [2017-08-21 11:26:12] [DEBUG poller.c:497] Start polling
[464EB700] [2017-08-21 11:26:26] [DEBUG response.c:104] Recalculating date header
[464EB700] [2017-08-21 11:26:26] [INFO response.c:189] [127.0.0.1] "GET /" 200 501 (Keep-Alive)
[464EB700] [2017-08-21 11:26:26] [DEBUG websocket.c:88] Websockets!
[464EB700] [2017-08-21 11:26:26] [ERROR codecs.c:389] Cant calculate SHA1 if gnutls is not compiled in! Aborting now
E.Bülbül
  • 39
  • 1
  • 9
  • Just saying `-Lgnutls` to gcc will not add any libraries, that's just specifying a library path where it will search. You must use `-l`, or perhaps rebuild Onion itself. – unwind Aug 21 '17 at 08:53
  • I have tried to add -L/usr/lib/x86_64-linux-gnu (that directory contains *gnults.so files) however, it resulted in the same error. – E.Bülbül Aug 21 '17 at 09:10
  • Are you compiling the project using cmake? – Claudiu Aug 21 '17 at 09:31
  • There is a provided CMakeLists.txt file in the example folder but when I run it, it does not create a make file. Txt file contains: add_executable(websockets websockets.c) target_link_libraries(websockets onion) – E.Bülbül Aug 21 '17 at 09:45
  • There was too much text for a comment so I posted an answer. Please let me know if you have problems with that approach. – Claudiu Aug 21 '17 at 10:52

1 Answers1

2

There should be no need to compile the example separately, it should be automatically compiled along with the entire project. For example if you are in the main package directory, create a clean directory and run cmake from it:

mkdir build && cd build
cmake ..

Then look through the output of cmake and make sure all 3rd party libraries and other dependencies are found. For gnutls it should look like the following:

-- Found GnuTLS: /usr/lib/libgnutls.so (found version "3.5.13")
-- Found GCrypt: /usr/include (found version "1.7.7")
-- SSL support is compiled in.

If instead you get an error message like:

Gnutls or gcrypt not found. SSL support is not compiled in.

, you must make sure that libgnutls.so is installed and can be found in the default search paths (/usr/lib/ for example).

After you fix the cmake errors and run make, you should find the example in examples/websockets/websockets.

Claudiu
  • 1,966
  • 4
  • 24
  • 35
  • Thank you, that solved my problem, I was not paying attention to the output since it had finished (I assumed it was OK because it finished.). Rookie mistake. – E.Bülbül Aug 21 '17 at 11:58