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

simple_example as static build for managed server #251

Closed dancesWithCycles closed 1 year ago

dancesWithCycles commented 1 year ago

Hi folks, I am wondering if I can use the ulfius ecosystem also on managed servers where I can not install dependencies due to privilege limitations.

That is why I try to build a static executable of simple_example for a proof of concept.

I am stuck at this point.

$:~/git/github/ulfius/example_programs/simple_example$ make clean static
rm -f *.o simple_example
gcc -c -Wall -I../../include -I../include -D_REENTRANT   simple_example.c -DDEBUG -g -O0
gcc -o simple_example simple_example.o /usr/local/lib/liborcania.a /usr/local/lib/libyder.a /usr/local/lib/libulfius.a -ljansson -lmicrohttpd -lpthread -lgnutls
/usr/bin/ld: /usr/local/lib/libulfius.a(u_request.o): in function `ulfius_export_request_http':
u_request.c:(.text+0x1d11): undefined reference to `o_base64_encode_alloc'
collect2: error: ld returned 1 exit status
make: *** [Makefile:49: static] Error 1

I wanted to make sure all dependencies are installed (ulfius, yder, orcania). All those dependencies are installed to /usr/local/lib.

Do you have an idea which point I am missing?

Do you recommend building static executable binaries for managed servers or rather dynamic linked executable binaries for root servers where you install dependencies manually?

Cheers!

babelouest commented 1 year ago

Hello,

I'm not an expert in static build, the libraries can be built in static archive, but I don't use it like that.

Maybe you don't need to build as a static library, just install the library in a folder where you have the authorization, such as $HOME/lib, then add $HOME/lib in your environment variable LD_LIBRARY_PATH.

Just don't take my word for it, use the documentation available online about these techniques.

dancesWithCycles commented 1 year ago

Hi, Thank you very much for this advice. I know where you are heading. That is definitely an option and I will try it

Cheers!