This simple piece of code really gives me hard time, so could anyone be some kind and explain me what could possibly be wrong? I've got simple cpp file that uses class included from header file.
lib.h
namespace tnamespace {
class base{
virtual ~base() {};
};
class test/*: public base*/ {
public:
test();
test();
};
}
lib.cxx
#include "lib.h"
namespace tnamespace{
test::test() {};
test::~test() {}
}
start.cpp
#include <iostream>
#include <lib.h>
int main() {
tnamespace::test d;
return 0;
}
i use gcc version 4.1.2 20080704 and compile project with
g++ start.cpp -I./ext_lib -Wall
got following linker error
/tmp/ccK2v6GD.o: In function `main':
start.cpp:(.text+0x7a): undefined reference to `tnamespace::test::test()'
start.cpp:(.text+0x88): undefined reference to `tnamespace::test::~test()'
collect2: ld returned 1 exit status
i managed to find solution. I forgot to compile my lib. Proper g++ command
g++ start.cpp ext_lib/lib.cxx -I./ext_lib -Wall