I'm fairly new at this gcc stuff. So I successfully compiled a set of libraries from the source. How do I use them in my program? Do I need to include the library headers in my program? What arguments/options do I pass to gcc?
I'm fairly new at this gcc stuff. So I successfully compiled a set of libraries from the source. How do I use them in my program? Do I need to include the library headers in my program? What arguments/options do I pass to gcc?
Say for example your library is in
/home/me/work/thing/lib/libthingy.a
and it's corresponding header file is in
/home/me/work/thing/inc/thingy.h
To compile something using those, say
You would compile withCode:#include <thingy.h> int main ( ) { doAThing(); return 0; }
gcc -I/home/me/work/thing/inc main.c -L/home/me/work/thing/lib -lthingy
If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
If at first you don't succeed, try writing your phone number on the exam paper.