The module includes the body of the class file in the form of .inl. <<<<header.h>>>> #include <iostream> using namespace std;
class Hello { int i,j; public: Hello(int i_, int j_); void print(); }; <<<<<header.inl>>>> Hello::Hello(int i_, int j_) { i = i_; j = j_; } void Hello::print() { cout << "hello, there.\n" << endl; } <<<<module>>>> #include "header.h" #include "header.inl" using namespace std; void a() { cout << "a" << endl; } And the main program has the same .inl even though it doesn't use the class. <<<<main program>>>> #include "header.h" #include "header.inl" using namespace std; int main() { cout << "Hello" << endl; } When I try to combine the module together with the main file. g++ -c moduleb.cpp g++ <<main program>> moduleb.o -o du There are error messages that symbols are duplicated. /usr/bin/ld: multiple definitions of symbol Hello::Hello(int, int) modulea.o definition of Hello::Hello(int, int)in section (__TEXT,__text) moduleb.o definition of Hello::Hello(int, int)in section (__TEXT,__text) /usr/bin/ld: multiple definitions of symbol __ZN5HelloC2Eii.eh modulea.o definition of absolute __ZN5HelloC2Eii.eh (value 0x0) moduleb.o definition of absolute __ZN5HelloC2Eii.eh (value 0x0) I think there is a g++ flag that can suppress this kind of error. Any ideas? _______________________________________________ help-gplusplus mailing list help-gplusplus@gnu.org http://lists.gnu.org/mailman/listinfo/help-gplusplus