views:

80

answers:

3

Hello,

I am getting a linking error, and I'm not sure what its referring to.

Here is the error

1>Main.obj : error LNK2019: unresolved external symbol "public: void __thiscall BinaryHeap,class std::allocator > >,class Comp,class std::allocator > > >::insert(class Item,class std::allocator > > const &)" (?insert@?$BinaryHeap@V?$Item@V?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@@V?$Comp@V?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@@@@QAEXABV?$Item@V?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@@@Z) referenced in function "public: void __thiscall PriorityQueue,class std::allocator > >::insertItem(int,class std::basic_string,class std::allocator > const &)" (?insertItem@?$PriorityQueue@V?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@@QAEXHABV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@Z)

The code is rather long, however if you want me to post it I will.

thanks

+3  A: 

It's saying you're calling BinaryHeap::insert but no implementation of that function is being linked in. You must have header files around or the compiler would've failed when you tried to call an undeclared function; did you forget to link a BinaryHeap library?

Michael Mrozek
+2  A: 

Are you trying to define a templated BinaryHeap class? Are you declaring the insert method in the .h file and defining it in the .cc file?

That doesn't work on most compilers. You need to define template functions so they are available at compile time, not just link time. Move the function definition to the header file.

Stephen
+4  A: 

It is a template function, BinaryHeap<T, Comp>::insert(T const &). Your MSVC compiler doesn't support exportable templates (very few do). Make sure you defined (not just declared) this function in a header file, not a .cpp file.

Hans Passant