babelouest / ulfius

Web Framework to build REST APIs, Webservices or any HTTP endpoint in C language. Can stream large amount of data, integrate JSON data with Jansson, and create websocket services
https://babelouest.github.io/ulfius
GNU Lesser General Public License v2.1
1.07k stars 183 forks source link

Websocket not supported, please recompile ulfius with websocket support #161

Closed alexe100 closed 4 years ago

alexe100 commented 4 years ago

Hi, I am trying to test websocket example. I compiled ulfius with websockets support:

/home/user1/Downloads/ulfius/build/ulfius/build$ cmake .. -DWITH_WEBSOCKET=on -DBUILD_STATIC=on -- Found Jansson: /usr/lib/x86_64-linux-gnu/libjansson.so (found version "2.12") -- Found Jansson: /usr/lib/x86_64-linux-gnu/libjansson.so (found suitable version "2.12", minimum required is "2.4") -- GNU TLS support: ON -- Websocket support: on -- Outgoing requests support: ON -- Jansson library support: ON -- Yder support: ON -- Build uwsc application: ON -- Build static library: on -- Build testing tree: OFF -- Install the header files: ON -- Build RPM package: OFF -- Build documentation: OFF -- Configuring done -- Generating done -- Build files have been written to: /home/user1/Downloads/ulfius/build

Then make & make install Then in:

Downloads/ulfius/example_programs/websocket_example$ make

Then, executin:

./websocket_server Websocket not supported, please recompile ulfius with websocket support

Why?

Thanks

babelouest commented 4 years ago

Hello,

This could have many reasons.

What OS/version are you using? Do you have ulfius already installed as a package? What is the content of the file /usr/local/include/ulfius-cfg.h?

Usually this error is because another version of ulfius is already installed.

Also try to compile the example programs with cmake: https://github.com/babelouest/ulfius/blob/master/example_programs/README.md

alexe100 commented 4 years ago

ubuntu 19 I never installed it as a package. I compiled from sources.

ifndef _ULFIUS_CFGH

define _ULFIUS_CFGH

define ULFIUS_VERSION 2.6.6

define ULFIUS_VERSION_STR "2.6.6"

define ULFIUS_VERSION_MAJOR 2

define ULFIUS_VERSION_MINOR 6

define ULFIUS_VERSION_PATCH 6

define ULFIUS_VERSION_NUMBER ((ULFIUS_VERSION_MAJOR << 16) | (ULFIUS_VERSION_MINOR << 8) | (ULFIUS_VERSION_PATCH << 0))

/ #undef U_DISABLE_JANSSON / / #undef U_DISABLE_CURL / / #undef U_DISABLE_GNUTLS /

define U_DISABLE_WEBSOCKET

/ #undef U_DISABLE_YDER / / #undef U_WITH_FREERTOS / / #undef U_WITH_LWIP /

endif / _ULFIUS_CFGH /

Why does #define U_DISABLE_WEBSOCKET exists in there?

It seems that cmake does not compile the websocket_example. Hence, I compile it using make.

babelouest commented 4 years ago

I still can't reproduce your problem. It seems that you used the build static mode and enable the option WITH_WEBSOCKET so I used them too.

I run a Ubuntu 19.10, build ulfius using cmake with the following command:

$ mkdir build && cd build
$ cmake -DBUILD_STATIC=on -DWITH_WEBSOCKET=on ..
-- The C compiler identification is GNU 9.2.1
-- Check for working C compiler: /usr/bin/cc
-- Check for working C compiler: /usr/bin/cc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
-- Looking for __GNU_LIBRARY__
-- Looking for __GNU_LIBRARY__ - found
-- Looking for pthread.h
-- Looking for pthread.h - found
-- Looking for pthread_create
-- Looking for pthread_create - not found
-- Looking for pthread_create in pthreads
-- Looking for pthread_create in pthreads - not found
-- Looking for pthread_create in pthread
-- Looking for pthread_create in pthread - found
-- Found Threads: TRUE  
-- Found GnuTLS: /usr/lib/x86_64-linux-gnu/libgnutls.so (found version "3.6.9") 
-- Found mhd: /usr/local/lib/libmicrohttpd.so (found version "0.9.66") 
-- Found CURL: /usr/lib/x86_64-linux-gnu/libcurl.so (found version "7.65.3") 
-- Found Jansson: /usr/lib/x86_64-linux-gnu/libjansson.so (found version "2.12") 
-- Found Jansson: /usr/lib/x86_64-linux-gnu/libjansson.so (found suitable version "2.12", minimum required is "2.4") 
-- GNU TLS support: ON
-- Websocket support: on
-- Outgoing requests support: ON
-- Jansson library support: ON
-- Yder support: ON
-- Build uwsc application: ON
-- Build static library: on
-- Build testing tree: OFF
-- Install the header files: ON
-- Build RPM package: OFF
-- Build documentation: OFF
-- Configuring done
-- Generating done
-- Build files have been written to: /usr/local/src/ulfius/build
$ make && sudo make install
$ cat /usr/local/include/ulfius-cfg.h
#ifndef _ULFIUS_CFG_H_
#define _ULFIUS_CFG_H_

#define ULFIUS_VERSION 2.6.6
#define ULFIUS_VERSION_STR "2.6.6"

#define ULFIUS_VERSION_MAJOR 2
#define ULFIUS_VERSION_MINOR 6
#define ULFIUS_VERSION_PATCH 6

#define ULFIUS_VERSION_NUMBER ((ULFIUS_VERSION_MAJOR << 16) | (ULFIUS_VERSION_MINOR << 8) | (ULFIUS_VERSION_PATCH << 0))

/* #undef U_DISABLE_JANSSON */
/* #undef U_DISABLE_CURL */
/* #undef U_DISABLE_GNUTLS */
/* #undef U_DISABLE_WEBSOCKET */
/* #undef U_DISABLE_YDER */
/* #undef U_WITH_FREERTOS */
/* #undef U_WITH_LWIP */

#endif /* _ULFIUS_CFG_H_ */
babelouest commented 4 years ago

@alexe100 , any update?

alexe100 commented 4 years ago

no, gave up and looking to microhttpd

On Sun, Apr 12, 2020 at 9:29 PM Nicolas Mora notifications@github.com wrote:

@alexe100 https://github.com/alexe100 , any update?

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/babelouest/ulfius/issues/161#issuecomment-612671763, or unsubscribe https://github.com/notifications/unsubscribe-auth/ACVY5FWL5Q4JJMUMX6JO6BTRMIQD7ANCNFSM4MDRERMA .

babelouest commented 4 years ago

no problem, happy hacking!