Any help with a gcc command line?

Eliot Moss moss@cs.umass.edu
Sun Jul 13 12:21:35 GMT 2025


On 7/13/2025 4:10 AM, Fergus Daly via Cygwin wrote:

-lfoo is passed on to the linker (probably ld), which does a very simple
adjustment of the name, specifically to libfoo.a.  It searches for that name in
in directories of the link path, which is what the -L option controls.
(The .a is because of static linking; dynamic linking does a different name
adjustment.)

Some ideas:

- You could specify a particular version you want, such as -lreadline-77.6
   (made up numbers) if you have multiple version around distinguished in that
   way.

- You can place a preferred version in /usr/local/lib and make sure that
   /usr/local/lib is searched before /lib, by using suitable -L options.
   Note that ld's man page says that -L specified directories are searched
   *before* the default directories.  Thus: -L/usr/local/lib in this case.

While you can do complicated things with gcc and ld, modest perusal of the
ld man page might help you figure out -l and -L options that will most
suit your goals.

HTH -- Eliot Moss


More information about the Cygwin mailing list