[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: Linking a static library with -fPIC for flex

On Tue, Sep 05, 2006 at 04:50:24PM -0500, Manoj Srivastava wrote:
> Hi,
>         Starting with version 2.5.31-18 of flex we have started
>  providing a static library compiled with position independent code,
>  namely, libfl_pic.a, in addition to the normal libfl.a library. This
>  is my mail, in accordance to ?10.2 of the Debian policy.

In my opinion, libfl_pic.a is totally useless, see below.

>         The problem is with packages that contain shared libraries
>  with a flex scanner compiled in. Since flex generates code 
>  that is not self contained, and the missing symbols live in
>  libfl.a. 

Not self contained is quite overstated.  Actually libfl.a provide
exactly 2 symbols that are defined if the program lacks them. They are:

main(): I doubt you would want a shared library to provide a
simple-minded main() function ?

yywrap(): whose code is
int     yywrap (void) { return 1; }

So if you are to write a library that include a flex scanner, all you
have to do is to prvide your own yywrap() function, even if it is
just return 1; and you won't need to link with libfl.a.

Actually I always advise to provide main() and yywrap(), this way
the C file generated by flex can be compiled on a host where libfl.a is
not available.

libfl.a is only useful if you want quickly write and run a flex script
without writing the main loop. But people tend to use perl for that

Bill. <ballombe@debian.org>

Imagine a large red swirl here.

Reply to: