S
satya
hi,
I am using GNU g++ and GNU ar to create a C++ class library. I am
facing the following problem:
1.My class library has 3 classes say x,y,z organized in (x.h,x.cpp)
(y.h,y.cpp) (z.h,z.cpp).
2. Now I compiled all the classes using g++ -c x.cpp etc. obtaining
x.o y.o and z.o
3. I wrote a test file test.cpp using these classes.
4. I compiled the test file like this: g++ x.o y.o z.o test.cpp --
this was succesful -- produced an a.out
5. Now I made a library: ar -cr libmyclass.a x.o y.o z.o
6. g++ libmyclass.a test.cpp --> Undefined reference to x() !
(constructor)
7. I tried this too: g++ -L. -lmyclass test.cpp --> same error!
Does anyone know why ?
thanks!!
satya.
I am using GNU g++ and GNU ar to create a C++ class library. I am
facing the following problem:
1.My class library has 3 classes say x,y,z organized in (x.h,x.cpp)
(y.h,y.cpp) (z.h,z.cpp).
2. Now I compiled all the classes using g++ -c x.cpp etc. obtaining
x.o y.o and z.o
3. I wrote a test file test.cpp using these classes.
4. I compiled the test file like this: g++ x.o y.o z.o test.cpp --
this was succesful -- produced an a.out
5. Now I made a library: ar -cr libmyclass.a x.o y.o z.o
6. g++ libmyclass.a test.cpp --> Undefined reference to x() !
(constructor)
7. I tried this too: g++ -L. -lmyclass test.cpp --> same error!
Does anyone know why ?
thanks!!
satya.