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);
.
// code: foo.cpp
#include foo.h
int foo(int a)
{
return a+1;
}
then I compile the library first:
now I want to use these library in some file like:
// prog.cpp
#include "foo.h"
int main()
{
int i = foo(2);
return i;
}
how must I compile these now? I made:
g++ -L. -lfoo prog.cpp
but get an error because the function foo would not be found
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