Hi,
I have been struggling with this for quite a while now! Please help me figure this out.
I have 4 directories, "app", "lib", "game" and "widgets". Here, "widgets" is the newly added one. Things were fine before adding it. The linkage goes like this. App is the main directory where the linking takes place.
Before:
1) I compile the lib directory, in my mac, it creates many object files *.o and 1 final *.a file (liblibrary.a).
2) I compile the game directory, same way to obtain libgame.a
3) I compile the application directory and everything works fine.
Now: All the 1-3 steps above are just 2-4 with the first step being
1) compile widgets directory to create libwidgets.a (similar to the others).
But, when I tried the compile the app directory now, I get this error
1 2 3 4 5 6 7 8 9
|
Undefined symbols:
"int max<int>(vec<int> const&)", referenced from:
LPI(mat<int>&, int const&)in liblibrary.a(metrics.o)
"vec<int> unique<int>(mat<int> const&)", referenced from:
PR(mat<int>&) in liblibrary.a(metrics.o)
ld: symbol(s) not found
collect2: ld returned 1 exit status
make: *** [app] Error 1
| |
Here, the widgets has a template class file for vectors and matrices. In addition, it adds many utility function for this vector_matrix_class, for example to find the "unique" element of a vector etc... The files in widgets are this way.
1 2 3 4 5 6
|
ctl.h (vector and matrix class with templates)
unique.h and unique.cpp (includes ctl.h)
max.h and max.cpp (includes ctl.h)
...
...
widgets.h (includes all .h files like max.h, unique.h etc...)
| |
The new implementation of directory "lib" uses certain functions (max and unique) from this file and it works fine and compiles there. But I don't understand what the problem is in linking from "app" directory.
I am sorry if this is confusing. Please let me know so I can clarify. I have invested lots of time in figuring this out.. I hope some1 could help me out with this. I am desperate!!!
thank you very much in advance.