Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How does gcc recognize that -lfl corresponds to flex library?

Tags:

c

linux

gcc

when i compile lex.yy.c with lfl gcc recognizes that some .a file of the flex library might be needed to be linked with my code. similarly for yacc we specify the -ly compiler option.

in other words if i create a library, abc.a i want gcc to recognize that whenever a program is compiled with -labc it should link with the library abc.a. what configuration changes need to be done?

like image 600
Rohit Banga Avatar asked Dec 13 '22 02:12

Rohit Banga


1 Answers

The yacc library is named liby.so, and lives in something like /usr/lib, which is a directory that ld knows about.

Your abc library should be named libabc.so (or ".a" for a static lib), and should be placed in a directory that is searched by ld.

To add /home/foo/libs to the list of directories searched, add -L/home/foo/libs to the ld command.

like image 53
gnud Avatar answered Dec 17 '22 23:12

gnud