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

[Issue] example_programs: build failed #247

Closed dancesWithCycles closed 1 year ago

dancesWithCycles commented 1 year ago

Hi folks, Thank you so much for maintaining this repository. May I share the following issue with you?

Describe the issue I am following the readme for the example programs but end up with failure.

To Reproduce

$ cd example_programs
$ mkdir build
$ cd build
$ cmake ..
$ make

Cmake replies with the following response.

-- The C compiler identification is GNU 10.2.1
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: /usr/bin/cc - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Looking for __GNU_LIBRARY__
-- Looking for __GNU_LIBRARY__ - found
-- Found ZLIB: /usr/lib/x86_64-linux-gnu/libz.so (found version "1.2.11") 
-- Looking for pthread.h
-- Looking for pthread.h - found
-- Performing Test CMAKE_HAVE_LIBC_PTHREAD
-- Performing Test CMAKE_HAVE_LIBC_PTHREAD - Failed
-- 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 Ulfius: /usr/lib/x86_64-linux-gnu/libulfius.so (found version "2.7.1") 
-- Found Ulfius: /usr/lib/x86_64-linux-gnu/libulfius.so (found suitable version "2.7.1", minimum required is "2.6") 
-- Found Yder: /usr/lib/x86_64-linux-gnu/libyder.so (found version "2.0.7") 
-- Websocket support: ON
-- Outgoing requests support: ON
-- Jansson library support: ON
-- Yder library support: 
-- Configuring done
-- Generating done
-- Build files have been written to: /home/begerad/git/github/ulfius/example_programs/build

Make replies with the following response.

Scanning dependencies of target auth_client
[  3%] Building C object CMakeFiles/auth_client.dir/auth_example/auth_client.c.o
/home/begerad/git/github/ulfius/example_programs/auth_example/auth_client.c: In function ‘main’:
/home/begerad/git/github/ulfius/example_programs/auth_example/auth_client.c:95:35: error: ‘U_OPT_HTTP_URL_APPEND’ undeclared (first use in this function); did you mean ‘U_OPT_HTTP_URL’?
   95 |                                   U_OPT_HTTP_URL_APPEND, "/404",
      |                                   ^~~~~~~~~~~~~~~~~~~~~
      |                                   U_OPT_HTTP_URL
/home/begerad/git/github/ulfius/example_programs/auth_example/auth_client.c:95:35: note: each undeclared identifier is reported only once for each function it appears in
make[2]: *** [CMakeFiles/auth_client.dir/build.make:82: CMakeFiles/auth_client.dir/auth_example/auth_client.c.o] Error 1
make[1]: *** [CMakeFiles/Makefile2:123: CMakeFiles/auth_client.dir/all] Error 2
make: *** [Makefile:103: all] Error 2

Expected behavior I expected make to build the example programs.

System (please complete the following information):

I am happy with each and every hint in the right direction.

Cheers!

babelouest commented 1 year ago

Hello @dancesWithCycles ,

It seems that you try to build the example programs with an old version of the library.

You should try instead to build the example programs provided by the libulfius-dev package in your /usr/share/doc/libulfius-dev/examples/ulfius/example_programs/, or install the last version of ulfius provided the github repository, and build the example programs from there too.

The issue is similar to #248 so I won't copy paste the same answer, just FYI.

dancesWithCycles commented 1 year ago

Hi @babelouest , Thank you so much for the advice. It sounds like I was comparing applies with oranges.

Now, I removed the distribution package and head for the manual installation. Anyhow, I am struggling with the yder build process.

This is where I am stuck.

$ mkdir build
$ cd build/
$ cmake ..
-- The C compiler identification is GNU 10.2.1
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: /usr/bin/cc - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Looking for __GNU_LIBRARY__
-- Looking for __GNU_LIBRARY__ - found
CMake Error at /usr/share/cmake-3.18/Modules/FindPackageHandleStandardArgs.cmake:165 (message):
  Could NOT find Systemd (missing: SYSTEMD_LIBRARY SYSTEMD_INCLUDE_DIR)
Call Stack (most recent call first):
  /usr/share/cmake-3.18/Modules/FindPackageHandleStandardArgs.cmake:458 (_FPHSA_FAILURE_MESSAGE)
  cmake-modules/FindSystemd.cmake:47 (find_package_handle_standard_args)
  CMakeLists.txt:105 (find_package)

-- Configuring incomplete, errors occurred!
...

Any idea?

Cheers!

babelouest commented 1 year ago

Some required dependencies are missing, to build yder, install libjournald-dev or build yder without journald support, check yder documentation: https://github.com/babelouest/yder#prerequisites

Then, check in the documentation if all Ulfius' dependencies are installed: https://github.com/babelouest/ulfius/blob/master/INSTALL.md#prerequisites

dancesWithCycles commented 1 year ago

Hi @babelouest , journald was not part of the dependencies list. That is why I missed it. I build yder without journald. Finally, also the example_programs are build on my host and the simple_example server is acting as expected.

Cheers mate for your help! That is very much appreciated!