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?
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With