Panda 1.0.3, Template importing issue: BitMask<PN_uint32,

Building the new FractalSpline nodes as a library that links to libpanda.dll etc.

Mostly it builds ok, except that I get these messages:


fractalSplineRingNode.obj : error LNK2019: unresolved external symbol "__declspe
c(dllimport) public: __thiscall BitMask<unsigned long,32>::~BitMask<unsigned lon
g,32>(void)" (__imp_??1?$BitMask@K$0CA@@@QAE@XZ) referenced in function _$E2
fractalSplineTorusNode.obj : error LNK2019: unresolved external symbol "__declsp
ec(dllimport) public: __thiscall BitMask<unsigned long,32>::~BitMask<unsigned lo
ng,32>(void)" (__imp_??1?$BitMask@K$0CA@@@QAE@XZ) referenced in function _$E2
fractalSplineTubeNode.obj : error LNK2019: unresolved external symbol "__declspe
c(dllimport) public: __thiscall BitMask<unsigned long,32>::~BitMask<unsigned lon
g,32>(void)" (__imp_??1?$BitMask@K$0CA@@@QAE@XZ) referenced in function _$E2
fractalSplineBoxNode.obj : error LNK2019: unresolved external symbol "__declspec
(dllimport) public: __thiscall BitMask<unsigned long,32>::~BitMask<unsigned long
,32>(void)" (__imp_??1?$BitMask@K$0CA@@@QAE@XZ) referenced in function _$E2
fractalSplineCylinderNode.obj : error LNK2019: unresolved external symbol "__dec
lspec(dllimport) public: __thiscall BitMask<unsigned long,32>::~BitMask<unsigned
 long,32>(void)" (__imp_??1?$BitMask@K$0CA@@@QAE@XZ) referenced in function _$E2

There’s a bunch of these messages; this is just a sample.

We can actually mutate these errors into warnings about local linkage by commenting out the export_template_class line in bitMask.h (line 129).

However that still leaves:


fractalSplineNode.obj : error LNK2001: unresolved external symbol "public: virtu
al class BitMask<unsigned long,32> __thiscall PandaNode::get_legal_collide_mask(
void)const " (?get_legal_collide_mask@PandaNode@@UBE?AV?$BitMask@K$0CA@@@XZ)
fractalSplinePrismNode.obj : error LNK2001: unresolved external symbol "public:
virtual class BitMask<unsigned long,32> __thiscall PandaNode::get_legal_collide_
mask(void)const " (?get_legal_collide_mask@PandaNode@@UBE?AV?$BitMask@K$0CA@@@XZ
)

It looks like this class was not exported during the libpanda.dll build, but is being expected to be imported now.

I’m guessing maybe something to do with #define switches now are not the same as for the release build 1.0.3?

Currently I’m defining:


/MD /DWIN32_VC /DWIN32 /DFORCE_INLINING /DWITHIN_PANDA

The /DWIN32_VC seems absolutely essential; I think this triggers the EXPCL_xxx macros to do their thing. I was kindof hoping that adding the FORCE_INLINING would fix the BitMask issue, but no joy yet. WITHIN_PANDA doesnt seem to affect things either way, probably shouldnt be there, but it is defined in makepanda.py’s compilec function.

All Panda libraries and include files are those from the 1.0.3 release.

What do you think?

Hugh

Note that I’ve got this to link by:

  • replacing the export template line in bitMask.h with an export:

template class __declspec( dllexport ) BitMask<PN_uint32, 32 >;
  • creating a new file pandaNodeHack.cxx, which I link in:

// necessary so this whole thing links ok.

#include "pandaNode.h"

CollideMask PandaNode::
get_legal_collide_mask() const {
  return CollideMask::all_off();
}

This still generates warnings:


fractalSplineNode.obj : warning LNK4217: locally defined symbol ?lower_on@?$BitM
ask@K$0CA@@@SA?AV1@H@Z (public: static class BitMask<unsigned long,32> __cdecl B
itMask<unsigned long,32>::lower_on(int)) imported in function _$E1
fractalSplineNode.obj : warning LNK4217: locally defined symbol ?bit@?$BitMask@K
$0CA@@@SA?AV1@H@Z (public: static class BitMask<unsigned long,32> __cdecl BitMas
k<unsigned long,32>::bit(int)) imported in function _$E4
fractalSplineNode.obj : warning LNK4217: locally defined symbol ??1?$BitMask@K$0
CA@@@QAE@XZ (public: __thiscall BitMask<unsigned long,32>::~BitMask<unsigned lon
g,32>(void)) imported in function _$E2

but since these functions, excluding the pandaNodeHack one, are all inline AFAIK, maybe its ok?

Hugh

Ok, this worked :slight_smile:

Also, the great news is: by doing it this way, panda is being built with full optimizations! So the frame rate jumped from 5fps (no optimizations) to 30! A six-fold increase.

Admittedly we are comparing Geoms to qpGeoms, so its not really a fair comparison, but its good news anyway.

Hugh

There should be a way to solve this linking error without having to resort to the hack you describe. We have lots of code that links with libpanda.dll and does not have a problem with BitMask32. But your error messages sure do suggest that BitMask32 wasn’t properly exported for some reason, which is indeed strange.

David