c++ undefined references with static library
- by stupid_idiot
hi guys i'm trying to make a static library from a class but when trying to use it i always get errors with undefined references on anything. the way i proceeded was creating the object file like
g++ -c myClass.cpp -o myClass.o
and then packing it with
ar rcs myClass.lib myClass.o
there is something i'm obviously missing generaly with this.. i bet it's something with symbols..
thx for any advices, i know it's most probably something i could find out if reading some tutorial so sorry if bothering with stupid stuff again :)
edit:
myClass.h:
class myClass{
public:
myClass();
void function();
};
myClass.cpp:
#include "myClass.h"
myClass::myClass(){}
void myClass::function(){}
program using the class:
#include "myClass.h"
int main(){
myClass mc;
mc.function();
return 0;
}
finally i compile it like this:
g++ -o main.exe -L. -l myClass main.cpp