On Mon, 21 Jul 2003 10:11:22 +0800
Verdi March
On Sunday 20 July 2003 20:19, Philipp Thomas wrote:
In your case, try linking like this:
g++ -o haha Kelas.o coba.o
and it should succeed :)
Hi, I just tried your suggestion, but it still fail to link:
cincai@nus-cincaipatron:/tmp> g++ -o haha Kelas.o coba.o coba.o(.text+0x18): In function `main': : undefined reference to `Kelas<int>::Kelas[in-charge]()' coba.o(.text+0x32): In function `main': : undefined reference to `Kelas<int>::getInt() const' collect2: ld returned 1 exit status
OTOH, if I modified Kelas.h to: ==================== #ifndef KELAS_H #define KELAS_H
class Kelas { ... }; #include Kelas.cpp #endif ===================
I can compile coba.cpp with just g++ -o haha coba.cpp AFAIK. The Linux linker does not support export. I've tried to build with template class member functions in a separate c++ file, and have not been able to make it work. As above, the solution is to have include everything in the header files. -- Jerry Feldman
Boston Linux and Unix user group http://www.blu.org PGP key id:C5061EA9 PGP Key fingerprint:053C 73EC 3AC1 5C44 3E14 9245 FB00 3ED5 C506 1EA9