Hello all,

I'm using some libraries made in C, in my C++ program. I must design a library that will basically encapsulate this C library. There is a test1.c example of the use of the library. I worked so far 2 classes:

Code:
class base_lvl1;
class base_lvl2;
each in it's own .h,.cpp pair, denoted here by base_lvl1.h(.cpp) and base_lvl2.h(.cpp). The only include test1.c have is original.h.

I made a base_inc.h file to include the needed include files. The files include list are below:

Code:
//base_inc.h
#include "base_lvl2.h"

...

//base_lvl2.h
#include "base_lvl1.h"

..

//base_lvl1.h
#include "original.h"
I've searched around and found I need the extern C directive, and original.h already does that.

My first test (test1.cpp) was a copy of test1.c, and it compiled. test1.cpp #include original.h

My second test (test2.cpp) was the creation of class base_lvl1 and the substitution of it's associated not encapsulated data by it, and it compiles. test2.cpp #include base_lvl1.h.

My third test (test3.cpp) was the creation of class base_lvl2 and the substitution of it's associated not encapsulated data by it, and it does not compile. test3.cpp #include base_lvl2.h

To explain exactly where the error goes:
- I can generate base_lvlx.o
- I can't compile test3.cpp with the line
Code:
$(CXX)  -o $@ $< $(I) $(LIB) $(LIB2) $(CXXFLAGS)
but test1.cpp and test2.cpp works
- If I try to generate test3.o first, and then use the line above, only test3.o is generated, and the error is the same.
- The error is in base_lvl2.o:
Code:
In function 'xxx::xxx::xxx':
base_lvl2.cpp:(.text+0x2f): undefined reference to 'orig_func'
where orig_func is a function that was is test1.c, test1.cpp and test2.cpp directly, but was moved to base_lvl2.cpp.

Does anyone have any idea of why is that happening?