I have a helper class that needs a template definition and works fine locally.
Now I try to put it in a static libary and use it in another program.
But when I use it, the linker reports a non-existent symbol. Is it possible to export the template definition somehow?
core_global.h
#pragma once
#include <QtCore/qglobal.h>
#define CORE_EXPORT Q_DECL_EXPORT
helper.h
#pragma once
#include "core_global.h"
template <typename E>
class CORE_EXPORT Helper
{
public:
Helper();
E fromString(const QString& text);
QString toString(E value);
};
helper.cpp
#include "Helper.h"
template<typename E>
Helper<E>::Helper()
{
}
template<typename E>
E Helper<E>::fromString(const QString& text)
{
// do something
return {};
}
template<typename E>
QString Helper<E>::toString(E value)
{
//do something
return {};
}