kristapsdz / kcgi

minimal CGI and FastCGI library for C/C++
https://kristaps.bsd.lv/kcgi
ISC License
278 stars 40 forks source link

samples - add libmd if Linux detected #104

Closed Un1Gfn closed 1 year ago

Un1Gfn commented 2 years ago

Building samples fail[A].

Package libmd (arch) (debian (dev)) provides the following: ) MD5{Init,Update,Final}.3.gz ) libmd.pc ) libmd.so

It seems that either -lmd or pkg-config --libs libmd should be added ) for sample(s) target ) if the build system detects Linux instead of BSD

I can't make a PR. I found no configure.ac and don't know how ./configure is generated :/ BSD noob


[A]

$ bmake -k -j1 samples
cc -g -W -Wall -Wextra -Wmissing-prototypes -Wstrict-prototypes -Wwrite-strings -Wno-unused-parameter  -DSANDBOX_SECCOMP_DEBUG -DENABLE_SECCOMP_FILTER=1 -c sample.c
cc -g -W -Wall -Wextra -Wmissing-prototypes -Wstrict-prototypes -Wwrite-strings -Wno-unused-parameter  -DSANDBOX_SECCOMP_DEBUG -DENABLE_SECCOMP_FILTER=1 -c sample-fcgi.c
cc -g -W -Wall -Wextra -Wmissing-prototypes -Wstrict-prototypes -Wwrite-strings -Wno-unused-parameter  -DSANDBOX_SECCOMP_DEBUG -DENABLE_SECCOMP_FILTER=1 -c sample-cgi.c
cc -o sample-cgi -static sample-cgi.o
cc -o sample-fcgi -static sample-fcgi.o -L. libkcgi.a -lz
/usr/bin/ld: libkcgi.a(child.o): in function `kworker_child_bodymd5':
/home/darren/.cache/paru/clone/kcgi/src/kcgi/child.c:1368: undefined reference to `MD5Init'
/usr/bin/ld: /home/darren/.cache/paru/clone/kcgi/src/kcgi/child.c:1369: undefined reference to `MD5Update'
/usr/bin/ld: /home/darren/.cache/paru/clone/kcgi/src/kcgi/child.c:1370: undefined reference to `MD5Final'
collect2: error: ld returned 1 exit status
*** [sample-fcgi] Error code 1

bmake: stopped in /home/darren/.cache/paru/clone/kcgi/src/kcgi
c++ -g -W -Wall -Wextra -Wmissing-prototypes -Wstrict-prototypes -Wwrite-strings -Wno-unused-parameter  -static -o samplepp samplepp.cc -L. libkcgi.a -lz
cc1plus: warning: command-line option ‘-Wmissing-prototypes’ is valid for C/ObjC but not for C++
cc1plus: warning: command-line option ‘-Wstrict-prototypes’ is valid for C/ObjC but not for C++
/usr/bin/ld: libkcgi.a(child.o): in function `kworker_child_bodymd5':
/home/darren/.cache/paru/clone/kcgi/src/kcgi/child.c:1368: undefined reference to `MD5Init'
/usr/bin/ld: /home/darren/.cache/paru/clone/kcgi/src/kcgi/child.c:1369: undefined reference to `MD5Update'
/usr/bin/ld: /home/darren/.cache/paru/clone/kcgi/src/kcgi/child.c:1370: undefined reference to `MD5Final'
collect2: error: ld returned 1 exit status
*** [samplepp] Error code 1

bmake: stopped in /home/darren/.cache/paru/clone/kcgi/src/kcgi
cc -o sample -static sample.o -L. libkcgihtml.a libkcgi.a -lz
/usr/bin/ld: libkcgi.a(child.o): in function `kworker_child_bodymd5':
/home/darren/.cache/paru/clone/kcgi/src/kcgi/child.c:1368: undefined reference to `MD5Init'
/usr/bin/ld: /home/darren/.cache/paru/clone/kcgi/src/kcgi/child.c:1369: undefined reference to `MD5Update'
/usr/bin/ld: /home/darren/.cache/paru/clone/kcgi/src/kcgi/child.c:1370: undefined reference to `MD5Final'
collect2: error: ld returned 1 exit status
*** [sample] Error code 1

bmake: stopped in /home/darren/.cache/paru/clone/kcgi/src/kcgi
kristapsdz commented 1 year ago

I don't have libmd-dev installed on my Linux machine, but it works because configure picks up that the MD5 functions don't exist and provides a compat layer withihn libkcgi.a, so the Makefile works as-is. I don't know why yours doesn't.

However, Linux works best by using libbsd-dev, which pulls in libmd-dev:

CFLAGS=$(pkg-config --cflags libbsd-overlay) \
  ./configure LDFLAGS=$(pkg-config --libs libbsd-overlay)

I've now added this to the main README.

Anyway, I've added the MD5 library bits to the sample build, which was indeed missing. Thanks again!