adokter / rsl

TRMM Radar Software Library (RSL)
https://trmm-fc.gsfc.nasa.gov/trmm_gv/software/rsl/
Other
25 stars 6 forks source link

conflict with libfl / flex #10

Open adokter opened 4 years ago

adokter commented 4 years ago

RSL completes compilation, but linking the rsl library to my own code fails. In particular, I get the following linking error:

/usr/local/trmm/lib/librsl.so: undefined reference to `yywrap'

It seems RSL has linked to yywrap in my local libfl library, instead of to RLS's native yywrap function, see here contents of libfl.a, part of flex:

nm ./x86_64-linux-gnu/libfl.a

libmain.o:
                 U exit
                 U _GLOBAL_OFFSET_TABLE_
0000000000000000 T main
                 U yylex

libyywrap.o:
0000000000000000 T yywrap

This library is installed on Ubuntu by apt-get:

apt search libfl | grep installed
> libfl-dev/bionic,now 2.6.4-6 amd64 [installed,automatic]
> libfl2/bionic,now 2.6.4-6 amd64 [installed,automatic]

The issue is related to these lines in the Makefile of RSL generated after running ./configure. It seems the -lfl library is incorrectly selected by RSL's build system:

LEXLIB = -lfl
LIBS = -L/usr/local/trmm/lib -ljpeg -lz -lm -lbz2 -lfl

To force the correct installation, change the -lfl flag into -ll, as follows:

LEXLIB = -ll
LIBS = -L/usr/local/trmm/lib -ljpeg -lz -lm -lbz2 -ll

Changing these lines manually fixed the problem

adokter commented 4 years ago

The problem also resolves on an Ubuntu system if the package flex-old instead of flex is installed

ruffner commented 4 years ago

Another fix for this is to edit the Makefile to statically link against flex

LEXLIB = /usr/lib/x86_64-linux-gnu/libfl.a
LIBS = -L/usr/local/trmm/lib -ljpeg -lz -lm -lbz2 /usr/lib/x86_64-linux-gnu/libfl.a