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.08k stars 182 forks source link

undefined reference to `ulfius_websocket_wait_close' #157

Closed alexe100 closed 4 years ago

alexe100 commented 4 years ago

Hi After compiling ulfius as:

cd orcania/ make && sudo make install cd ../yder/ make && sudo make install cd ../ulfius/ mkdir build cd build cmake .. make && sudo make install

when I compile a program with websockets support:

... -lulfius -lorcania -ljansson -lyder

I get:

undefined reference to ulfius_websocket_wait_close' undefined reference toulfius_websocket_send_message' undefined reference to ulfius_websocket_wait_close' undefined reference toulfius_websocket_send_fragmented_message' undefined reference to ulfius_websocket_wait_close' undefined reference toulfius_websocket_send_message' undefined reference to ulfius_websocket_wait_close' undefined reference toulfius_websocket_send_message'

Thanks Alex

babelouest commented 4 years ago

Hello,

Websocket support must have been disabled because of missing dependencies. Do you have all the libraries required with the correct version? What system are you using?

alexe100 commented 4 years ago

Linux ubuntu.Where is the info about those extra libs that must be installed and updated?

alexe100 commented 4 years ago

Doing a make clean and make all on the websocket sample, there is no error. Then: ./websocket_client Websocket not supported, please recompile ulfius with websocket support

Cmaking again:

$cmake .. -- 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: OFF -- Build testing tree: OFF -- Install the header files: ON -- Build RPM package: OFF -- Build documentation: OFF -- Configuring done -- Generating done

babelouest commented 4 years ago

Your cmake log is ok, websocket and uwsc are enabled.

The install documentation may help you with the requirements: https://github.com/babelouest/ulfius/blob/master/INSTALL.md#prerequisites

If it possible that you already have installed ulfius via the Ubuntu package?

alexe100 commented 4 years ago

No, I always prefer buld from source. Hence apart from this command:

apt-get install libmicrohttpd-dev libjansson-dev libcurl4-gnutls-dev libgnutls28-dev libgcrypt20-dev

No other apt command was used to instal something related with ulfius. By the way, I have executed again the command above and the result is:

Reading package lists... Done Building dependency tree
Reading state information... Done libjansson-dev is already the newest version (2.12-1build1). libmicrohttpd-dev is already the newest version (0.9.62-1). libcurl4-gnutls-dev is already the newest version (7.64.0-2ubuntu1.2). libgcrypt20-dev is already the newest version (1.8.4-3ubuntu1.1). libgcrypt20-dev set to manually installed. libgnutls28-dev is already the newest version (3.6.5-2ubuntu1.1). 0 upgraded, 0 newly installed, 0 to remove and 2 not upgraded.

I am goinf to try to find all libulfius.so files on the system and delete them and then build ulfius again...

By the way I have these ones:

/usr/local/lib/libulfius.so.2.6 /usr/local/lib/libulfius.so.2.6.5 /usr/local/lib/libulfius.so

no... after rebuild it all I tried to execute websocket client sample and got:

Websocket not supported, please recompile ulfius with websocket support

babelouest commented 4 years ago

What does your ulfius-cfg.h says? It must be in the same folder where ulfius.h is installed: /usr/include or /usr/local/include

Also, what is the output of the make command?

alexe100 commented 4 years ago

$sudo find / -iname 'ulfius-cfg.h' /usr/local/include/ulfius-cfg.h /usr/include/ulfius-cfg.h

$sudo find / -iname 'ulfius.h' /usr/local/include/ulfius.h /usr/include/ulfius.h

$cat /usr/include/ulfius-cfg.h

ifndef _ULFIUS_CFGH

define _ULFIUS_CFGH

define ULFIUS_VERSION 2.6.5

define ULFIUS_VERSION_STR "2.6.5"

define ULFIUS_VERSION_MAJOR 2

define ULFIUS_VERSION_MINOR 6

define ULFIUS_VERSION_PATCH 5

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_CFGH /

make clean make [ 10%] Building C object CMakeFiles/ulfius.dir/src/u_map.c.o [ 20%] Building C object CMakeFiles/ulfius.dir/src/u_request.c.o [ 30%] Building C object CMakeFiles/ulfius.dir/src/u_response.c.o [ 40%] Building C object CMakeFiles/ulfius.dir/src/u_send_request.c.o [ 50%] Building C object CMakeFiles/ulfius.dir/src/u_websocket.c.o [ 60%] Building C object CMakeFiles/ulfius.dir/src/yuarel.c.o [ 70%] Building C object CMakeFiles/ulfius.dir/src/ulfius.c.o [ 80%] Linking C shared library libulfius.so [ 80%] Built target ulfius [ 90%] Building C object CMakeFiles/uwsc.dir/tools/uwsc/uwsc.c.o [100%] Linking C executable uwsc [100%] Built target uwsc

babelouest commented 4 years ago
$sudo find / -iname 'ulfius-cfg.h'
/usr/local/include/ulfius-cfg.h
/usr/include/ulfius-cfg.h

$sudo find / -iname 'ulfius.h'
/usr/local/include/ulfius.h
/usr/include/ulfius.h

You do have 2 versions of ulfius installed, the one in /usr/include must be an old version

babelouest commented 4 years ago

Does sudo apt remove libulfius remove something?

alexe100 commented 4 years ago

I was trying to deploy the service/server on the target computer... In the meanwhile, I reinstalled the operating system and ulfius and now it works! I dont know why because I followed the same steps but now it works.

Thanks a lot