i want to know how i can use a static library in C++ which i created, first the lib:
// header: foo.h
int foo(int a);
.
//
You want:
g++ -L. prog.cpp -lfoo
Unfortunately, the ld linker is sensitive to the order of libraries. When trying to satisfy undefined symbols in prog.cpp, it will only look at libraries that appear AFTER prog.cpp on the command line.
You can also just specify the library (with a path if necessary) on the command line, and forget about the -L flag:
g++ prog.cpp libfoo.a