[Libwebsockets] suggestion: Add include/libsockets.h link to build directory

Per Bothner per at bothner.com
Sun Feb 26 07:48:50 CET 2017


On 02/25/2017 06:43 PM, Andy Green wrote:
>
>
> On February 26, 2017 11:27:29 AM GMT+09:00, Per Bothner <per at bothner.com> wrote:
>> It would be helpful to be able to use the build directory "in-place"
>> i.e. after 'make' but without 'make install'.
>
> The main things that have led to it not being easy to use like that are
>
>  - binding the .so at runtime is usually a matter of ldconfig and /etc/ld.so.conf, implying copying the libs somewhere that's set up to look at

At least on GNU/Linux, you can specify LD_LIBRARY_PATH to link (at run-time)
against non-system libraries.

>  - the test apps want assets in a /usr/share type place set at build-time

DomTerm uses the "where am I" library (https://github.com/gpakosz/whereami)
to find the executable, and uses ../lib or ../share relative to that.
I make a point of the DomTerm build directory being set up so running-in-place
works teh asme way as after installation.

> I can imagine how to make the second fall back to looking at some ../ dir also in build, but is your scheme going to be okay finding the libs at runtime like that as well as link-time?

Since libwebsockets also builds libwebsockets.a, I decided it
makes to use that, when building DomTerm against a non-installed libwebsockets:

if test "$with_libwebsockets" != "no"; then
   PKG_CHECK_MODULES(JSON_C, json-c)
   PKG_CHECK_MODULES(OPENSSL, openssl)
   case "${with_libwebsockets}" in
     "yes" | "")
       PKG_CHECK_MODULES(LIBWEBSOCKETS, libwebsockets)
       ;;
     *)
       #LIBWEBSOCKETS_LIBS="-L ${with_libwebsockets}/lib -lwebsockets"
       LIBWEBSOCKETS_LIBS="${with_libwebsockets}/lib/libwebsockets.a"
       LIBWEBSOCKETS_CFLAGS="-I${with_libwebsockets}/include"
       ;;
   esac
fi

This assumes an include link as I suggested, though I could replace
setting LIBWEBSOCKETS_CFLAGS by:
   LIBWEBSOCKETS_CFLAGS="-I${with_libwebsockets}/../lib"

for example.

Using -I${with_libwebsockets}/include does seem more elegant though.
-- 
	--Per Bothner
per at bothner.com   http://per.bothner.com/



More information about the Libwebsockets mailing list