Problem exporting boost.variant from dll

Hi, all.

I have a boost::variant problem. I have a dll to which I've added a couple classes using boost::variant. Everything compiles fine, but during build, I get the following error:

NPoint.obj : error LNK2019: unresolved external symbol "public: class boost::variant<bool,unsigned char,double,float,short,int,struct boost::detail::variant::void_,struct boost::detail::variant::void_,struct boost::detail::variant::void_,struct boost::detail::variant::void_,struct boost::detail::variant::void_,struct boost::detail::variant::void_,struct boost::detail::variant::void_,struct boost::detail::variant::void_,struct boost::detail::variant::void_,struct boost::detail::variant::void_,struct boost::detail::variant::void_,struct boost::detail::variant::void_,struct boost::detail::variant::void_,struct boost::detail::variant::void_> __thiscall neo::NPoint::getValue(void)" (?getValue@NPoint@neo@@QAE?AV?$variant@_NENMFHUvoid_@0detail@boost@@U1023@U1023@U1023@U1023@U1023@U1023@U1023@U1023@U1023@U1023@U1023@U1023@U1023@@boost@@XZ) referenced in function "public: bool __thiscall neo::NPoint::getWriteValue(class boost::variant<bool,unsigned char,double,float,short,int,struct boost::detail::variant::void_,struct boost::detail::variant::void_,struct boost::detail::variant::void_,struct boost::detail::variant::void_,struct boost::detail::variant::void_,struct boost::detail::variant::void_,struct boost::detail::variant::void_,struct boost::detail::variant::void_,struct boost::detail::variant::void_,struct boost::detail::variant::void_,struct boost::detail::variant::void_,struct boost::detail::variant::void_,struct boost::detail::variant::void_,struct boost::detail::variant::void_> &)" (?getWriteValue@NPoint@neo@@QAE_NAAV?$variant@_NENMFHUvoid_@0detail@boost@@U1023@U1023@U1023@U1023@U1023@U1023@U1023@U1023@U1023@U1023@U1023@U1023@U1023@@boost@@@Z)

Here's how I've defined the variant in a header file that all classes in my project use:

#ifdef _NEO_EXPORTS
#define CLASS_DECLSPEC __declspec(dllexport)
#define EXPIMP_TEMPLATE
#else
#define CLASS_DECLSPEC __declspec(dllimport)
#define EXPIMP_TEMPLATE extern
#endif

#include <boost/variant.hpp>

typedef bool NBitValue;
typedef unsigned char NByteValue;
typedef double NDFloatValue;
typedef float NFloatValue;
typedef short int NWordValue;
typedef int NDWordValue;


// Instantiate template classes for export
EXPIMP_TEMPLATE template class CLASS_DECLSPEC boost::variant < NBitValue, NByteValue, NDFloatValue,NFloatValue, NWordValue, NDWordValue>;

typedef boost::variant <NBitValue, NByteValue, NDFloatValue,
NFloatValue, NWordValue, NDWordValue> NValue;


An example of how it is used in other classes:

namespace neo
{
class CLASS_DECLSPEC NPoint :
public NValueBase
{
public:

.....
bool getWriteValue(NValue& t);

Compiles fine, but the linker goes on to say:

" referenced in function "public: bool __thiscall neo::NPoint::getWriteValue .."


I've been using boost for the past two months in this project with no problem, but now I can't get this to link. I'm sure I'm doing something stupid. Does anyone have any insight?

Thanks in advance,
Tom





you might need to link another library... possibly one with variant in it... I still have yet to use boost, so can't say much. Did you compile all the libraries already and did you link the appropriate ones?
Is there an additional library for Boost.Variant? There isn't one listed in the "documentation," although I use the term documentation loosely in this case.

I am using some boost features that require lib files, and have included the lib directory in my project. They do not have a problem. Perhaps there is a .lib file I need to specifically mention in the linker settings? I can find no mention of one in the doc.
Hmm, where is getWriteValue() defined at?
Do you mean is it in an external library? No, it is part of the same project; it's not external to the project Boost.Variant is being used in.
Found it. I had a problem in a class declaration that was using Variant. The error message was misleading.

Thanks!
Topic archived. No new replies allowed.