In a library i'm working on, I have something like this template class in a header file:
template <int something>
class Base {
public:
virtual ~Base(); // Implemented in c++ file
}
class Derived : public Base<100> {
public:
~Derived() override = default();
}
The destructor is implemented like so:
template <int something>
Base<something>::~Base() {
destroyBase();
}
This code is compiled as a static library.
Then, I have this code in a sample:
{
Derived x;
x.doSomething();
} // X gets destroyed
I compile the executable and link the static library. This works fine on Ubuntu, but when I try it on mac, the linking fails with
Undefined symbols for architecture x86_64:
"Base<100>::~Base()", referenced from:
_main in my_sample.cpp.o
In both cases, I'm using clang and compiling with the exact same cmake settings. All the other symbols defined in the cpp file are defined. This is the only undefined symbol. What is happening?