How to include needed C library using gcc?

前端 未结 6 818
难免孤独
难免孤独 2020-11-29 02:09

I am trying to compile the simple C example from this Tutorial on Ubuntu using gcc. What do I have to use as argument for gcc to include the needed libraries for #incl

6条回答
  •  心在旅途
    2020-11-29 02:33

    Use the -l command line option. You can specify the library search path with the -L option. E.g:

    gcc -o myprogram -lfoo -L/home/me/foo/lib myprogram.c
    

    This will link myprogram with the static library libfoo.a in the folder /home/me/foo/lib.

提交回复
热议问题