What's wrong with this linking?

O

Orgad

I wrote a simple program (in which I reused a data structure), but it
refuses to link. Can anyone here please help me?

Notice that Region2D.cpp IS in the compilation, and the "unresolved"
functions DO exist there!

I'm using Microsoft Visual C++ 6.0.


The output for the Rebuild All:

Compiling...
main.cpp
QuadMesh.cpp
QuadTree.cpp
Region2D.cpp
Tree.cpp
Linking...
main.obj : error LNK2001: unresolved external symbol "public: virtual
__thiscall Rage::NTree::Region2D<char>::~Region2D<char>(void)"
(??1?$Region2D@D@NTree@Rage@@UAE@XZ)
main.obj : error LNK2001: unresolved external symbol "public: void
__thiscall Rage::NTree::Region2D<char>::initialize(int,int,char *)"
(?initialize@?$Region2D@D@NTree@Rage@@QAEXHHPAD@Z)
main.obj : error LNK2001: unresolved external symbol "public:
__thiscall Rage::NTree::Region2D<char>::Region2D<char>(void)"
(??0?$Region2D@D@NTree@Rage@@QAE@XZ)
Debug/Rage.exe : fatal error LNK1120: 3 unresolved externals
Error executing link.exe.

Rage.exe - 4 error(s), 0 warning(s)

The source files are here:
http://www.cc.jct.ac.il/~shaneh/qtree.zip
 
J

John Harrison

Orgad said:
I wrote a simple program (in which I reused a data structure), but it
refuses to link. Can anyone here please help me?

Notice that Region2D.cpp IS in the compilation, and the "unresolved"
functions DO exist there!

But that's the wrong place!!

Template functions and classes should always go in header files, otherwise
you will get linking problems.

This is a FAQ 'How can I avoid linker errors with my template classes',
http://www.parashift.com/c++-faq-lite/containers-and-templates.html#faq-34.14

john
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,997
Messages
2,570,241
Members
46,831
Latest member
RusselWill

Latest Threads

Top