rsyslog / liblognorm

a fast samples-based log normalization library
http://www.liblognorm.com
GNU Lesser General Public License v2.1
99 stars 64 forks source link

compilation/linking ignores JSON_C_LIBS #346

Closed cbueche closed 3 years ago

cbueche commented 3 years ago

On SUSE Linux Enterprise Server 12.5, I'm trying to compile rsyslogd to use a "modern" libfastjson, as the included one is problematic. So I compile the chain libfastjson, then liblognorm, and at the end rsyslogd. I give these packages my own %{name} and prefix (/opt/XXX) so they do not collide with the SLES ones. I do use the RPM packaging with *:spec files so I end up with installable packages.

Unfortunately, while building liblognorm, and despite setting JSON_C_CFLAGS / JSON_C_LIBS :

export CC=gcc-8
export JSON_C_CFLAGS="-I/opt/libfastjson/include/libfastjson"
export JSON_C_LIBS="-L/opt/libfastjson/lib64 -lfastjson"

The configure/Make process still links with /usr/lib64/libfastjson.so.4. Interestingly, and for whatever reason, there is no liblognorm5-devel in my repository so json.h is not available and JSON_C_CFLAGS is used to find it, and it works... Only, I end up with my shared libs and binary to be linked against /usr/lib64/libfastjson.so.4 :

ldd /opt/lognorm/bin/lognormalizer 
        linux-vdso.so.1 (0x00007fffc3404000)
        libfastjson.so.4 => /usr/lib64/libfastjson.so.4 (0x00007f966aeb6000)
        liblognorm.so.5 => /opt/lognorm/lib64/liblognorm.so.5 (0x00007f966ac90000)
        libestr.so.0 => /usr/lib64/libestr.so.0 (0x00007f966aa8c000)
        libc.so.6 => /lib64/libc.so.6 (0x00007f966a6e7000)
        libpcre.so.1 => /usr/lib64/libpcre.so.1 (0x00007f966a478000)
        /lib64/ld-linux-x86-64.so.2 (0x00007f966b0c0000)
        libpthread.so.0 => /lib64/libpthread.so.0 (0x00007f966a25b000)```

Anyone has an idea ? I just can't get my head around the multiple Makefiles and why the order of the proposed lib is wrong.

Notes : I cannot remove the existing rsyslogd package and dependencies (used by system-admins). My own rsyslogd runs as distinct process and is used for network-only traffic sorting, filtering, etc.

cbueche commented 3 years ago

ok I found a workaround by adding -R... option in JSON_C_LIBS :

export JSON_C_LIBS="-L/opt/libfastjson/lib64 -R/opt/libfastjson/lib64 -lfastjson"

and now I get what I want, lognorm using my libfastjson instead of SLES's one :

ldd /opt/lognorm/bin/lognormalizer
        linux-vdso.so.1 (0x00007fff3a3ce000)
        libfastjson.so.4 => /opt/libfastjson/lib64/libfastjson.so.4 (0x00007fa196b84000)
        liblognorm.so.5 => /opt/lognorm/lib64/liblognorm.so.5 (0x00007fa19695e000)
        libestr.so.0 => /usr/lib64/libestr.so.0 (0x00007fa19675a000)
        libc.so.6 => /lib64/libc.so.6 (0x00007fa1963b5000)
        libpcre.so.1 => /usr/lib64/libpcre.so.1 (0x00007fa196146000)
        /lib64/ld-linux-x86-64.so.2 (0x00007fa196d8f000)
        libpthread.so.0 => /lib64/libpthread.so.0 (0x00007fa195f29000)