0

EDIT: Duplicate of C++ template, linking error

Thanks Bo, this is the same issue I'm having!

I'm using Cywgin with NetBeans 7.1 on Windows 7 x64.

I have one NetBeans project setup as a static library, all of the code written in C++.

When I include this library project in another NetBeans project and include the appropriate header files from the library, the linker fails to find the classes/functions in the library.

Any ideas what I did wrong?

Community
  • 1
  • 1
AAA
  • 1
  • 1
  • possible duplicate of [C++ template, linking error](http://stackoverflow.com/questions/1353973/c-template-linking-error) – Bo Persson Jan 10 '12 at 16:17
  • 1
    Using templates you need to include the definitions in the header file, so the compiler can see them. – Bo Persson Jan 10 '12 at 16:19

1 Answers1

0

Is this ptr class compiled in this first static library and only *.h is available as a interface to second one? If yes then in this first library template ptr wasn't created with int type and this kind of constructor/destructor isn't there so you can use it from second library.

The easiest way to deal with this is to include ptr.cpp and compile it also in second library. This will allow to create template code for int type during compilation. Another solution is to somehow use ptr template with int type in this first library so it will be created there.

Zuljin
  • 2,612
  • 17
  • 14