Linker error using notify

I’ve been trying to use notify in my project, however VS 2008 is giving me link errors :cry:

config_dna.h

#pragma once

#ifndef CPPPARSER

#include <pandabase.h>
#include <notifyCategoryProxy.h>

#pragma warning (disable : 4273)

NotifyCategoryDecl(dna, EXPCL_PANDASKEL, EXPTP_PANDASKEL);
void init_libpandadna();

#endif

config_dna.cxx

#include "config_dna.h"
#include <pandabase.h>
#include <dconfig.h>

Configure(config_dna);
NotifyCategoryDef(dna, "");

/* more config stuff */

The linker error is:

config_dna.obj : error LNK2019: unresolved external symbol "__declspec(dllimport
) public: class NotifyCategory * __thiscall NotifyCategoryProxy<class NotifyCate
goryGetCategory_dna>::init(void)" (__imp_?init@?$NotifyCategoryProxy@VNotifyCate
goryGetCategory_dna@@@@QAEPAVNotifyCategory@@XZ) referenced in function "public:
 __thiscall NotifyCategoryGetCategory_dna::NotifyCategoryGetCategory_dna(void)"
(??0NotifyCategoryGetCategory_dna@@QAE@XZ)
built/libpandadna.pyd : fatal error LNK1120: 1 unresolved externals

When I try to actually use the notify:

dna_cat.info() << "get_door_pos_hpr_from_block_number " << block_number << std::endl;    

Even more evil errors show up:

DNAStorage.obj : error LNK2019: unresolved external symbol "__declspec(dllimport
) public: class std::basic_ostream<char,struct std::char_traits<char> > & __this
call std::basic_ostream<char,struct std::char_traits<char> >::operator<<(class s
td::basic_ostream<char,struct std::char_traits<char> > & (__cdecl*)(class std::b
asic_ostream<char,struct std::char_traits<char> > &))" (__imp_??6?$basic_ostream
@DU?$char_traits@D@std@@@std@@QAEAAV01@P6AAAV01@AAV01@@Z@Z) referenced in functi
on "public: class NodePath __thiscall DNAStorage::get_door_pos_hpr_from_block_nu
mber(unsigned short)" (?get_door_pos_hpr_from_block_number@DNAStorage@@QAE?AVNod
ePath@@G@Z)
DNAStorage.obj : error LNK2019: unresolved external symbol "__declspec(dllimport
) public: class std::basic_ostream<char,struct std::char_traits<char> > & __this
call std::basic_ostream<char,struct std::char_traits<char> >::operator<<(unsigne
d short)" (__imp_??6?$basic_ostream@DU?$char_traits@D@std@@@std@@QAEAAV01@G@Z) r
eferenced in function "public: class NodePath __thiscall DNAStorage::get_door_po
s_hpr_from_block_number(unsigned short)" (?get_door_pos_hpr_from_block_number@DN
AStorage@@QAE?AVNodePath@@G@Z)
DNAStorage.obj : error LNK2019: unresolved external symbol "__declspec(dllimport
) public: class std::basic_ostream<char,struct std::char_traits<char> > & __this
call NotifyCategoryProxy<class NotifyCategoryGetCategory_dna>::info(bool)" (__im
p_?info@?$NotifyCategoryProxy@VNotifyCategoryGetCategory_dna@@@@QAEAAV?$basic_os
tream@DU?$char_traits@D@std@@@std@@_N@Z) referenced in function "public: class N
odePath __thiscall DNAStorage::get_door_pos_hpr_from_block_number(unsigned short
)" (?get_door_pos_hpr_from_block_number@DNAStorage@@QAE?AVNodePath@@G@Z)
DNAStorage.obj : error LNK2019: unresolved external symbol "__declspec(dllimport
) public: class std::basic_ostream<char,struct std::char_traits<char> > & __this
call std::basic_ostream<char,struct std::char_traits<char> >::flush(void)" (__im
p_?flush@?$basic_ostream@DU?$char_traits@D@std@@@std@@QAEAAV12@XZ) referenced in
 function "class std::basic_ostream<char,struct std::char_traits<char> > & __cde
cl std::endl(class std::basic_ostream<char,struct std::char_traits<char> > &)" (
?endl@std@@YAAAV?$basic_ostream@DU?$char_traits@D@std@@@1@AAV21@@Z)
DNAStorage.obj : error LNK2019: unresolved external symbol "__declspec(dllimport
) public: class std::basic_ostream<char,struct std::char_traits<char> > & __this
call std::basic_ostream<char,struct std::char_traits<char> >::put(char)" (__imp_
?put@?$basic_ostream@DU?$char_traits@D@std@@@std@@QAEAAV12@D@Z) referenced in fu
nction "class std::basic_ostream<char,struct std::char_traits<char> > & __cdecl
std::endl(class std::basic_ostream<char,struct std::char_traits<char> > &)" (?en
dl@std@@YAAAV?$basic_ostream@DU?$char_traits@D@std@@@1@AAV21@@Z)
DNAStorage.obj : error LNK2019: unresolved external symbol "__declspec(dllimport
) public: void __thiscall std::basic_ios<char,struct std::char_traits<char> >::s
etstate(int,bool)" (__imp_?setstate@?$basic_ios@DU?$char_traits@D@std@@@std@@QAE
XH_N@Z) referenced in function __catch$??$?6U?$char_traits@D@std@@@std@@YAAAV?$b
asic_ostream@DU?$char_traits@D@std@@@0@AAV10@PBD@Z$0
DNAStorage.obj : error LNK2019: unresolved external symbol "__declspec(dllimport
) public: int __thiscall std::basic_streambuf<char,struct std::char_traits<char>
 >::sputn(char const *,int)" (__imp_?sputn@?$basic_streambuf@DU?$char_traits@D@s
td@@@std@@QAEHPBDH@Z) referenced in function "class std::basic_ostream<char,stru
ct std::char_traits<char> > & __cdecl std::operator<<<struct std::char_traits<ch
ar> >(class std::basic_ostream<char,struct std::char_traits<char> > &,char const
 *)" (??$?6U?$char_traits@D@std@@@std@@YAAAV?$basic_ostream@DU?$char_traits@D@st
d@@@0@AAV10@PBD@Z)
DNAStorage.obj : error LNK2019: unresolved external symbol "__declspec(dllimport
) public: int __thiscall std::basic_streambuf<char,struct std::char_traits<char>
 >::sputc(char)" (__imp_?sputc@?$basic_streambuf@DU?$char_traits@D@std@@@std@@QA
EHD@Z) referenced in function "class std::basic_ostream<char,struct std::char_tr
aits<char> > & __cdecl std::operator<<<struct std::char_traits<char> >(class std
::basic_ostream<char,struct std::char_traits<char> > &,char const *)" (??$?6U?$c
har_traits@D@std@@@std@@YAAAV?$basic_ostream@DU?$char_traits@D@std@@@0@AAV10@PBD
@Z)
DNAStorage.obj : error LNK2019: unresolved external symbol "__declspec(dllimport
) public: class std::basic_streambuf<char,struct std::char_traits<char> > * __th
iscall std::basic_ios<char,struct std::char_traits<char> >::rdbuf(void)const " (
__imp_?rdbuf@?$basic_ios@DU?$char_traits@D@std@@@std@@QBEPAV?$basic_streambuf@DU
?$char_traits@D@std@@@2@XZ) referenced in function "class std::basic_ostream<cha
r,struct std::char_traits<char> > & __cdecl std::operator<<<struct std::char_tra
its<char> >(class std::basic_ostream<char,struct std::char_traits<char> > &,char
 const *)" (??$?6U?$char_traits@D@std@@@std@@YAAAV?$basic_ostream@DU?$char_trait
s@D@std@@@0@AAV10@PBD@Z)
DNAStorage.obj : error LNK2019: unresolved external symbol "__declspec(dllimport
) public: char __thiscall std::basic_ios<char,struct std::char_traits<char> >::f
ill(void)const " (__imp_?fill@?$basic_ios@DU?$char_traits@D@std@@@std@@QBEDXZ) r
eferenced in function "class std::basic_ostream<char,struct std::char_traits<cha
r> > & __cdecl std::operator<<<struct std::char_traits<char> >(class std::basic_
ostream<char,struct std::char_traits<char> > &,char const *)" (??$?6U?$char_trai
ts@D@std@@@std@@YAAAV?$basic_ostream@DU?$char_traits@D@std@@@0@AAV10@PBD@Z)
DNAStorage.obj : error LNK2019: unresolved external symbol "__declspec(dllimport
) public: class std::basic_ostream<char,struct std::char_traits<char> > * __this
call std::basic_ios<char,struct std::char_traits<char> >::tie(void)const " (__im
p_?tie@?$basic_ios@DU?$char_traits@D@std@@@std@@QBEPAV?$basic_ostream@DU?$char_t
raits@D@std@@@2@XZ) referenced in function "public: __thiscall std::basic_ostrea
m<char,struct std::char_traits<char> >::sentry::sentry(class std::basic_ostream<
char,struct std::char_traits<char> > &)" (??0sentry@?$basic_ostream@DU?$char_tra
its@D@std@@@std@@QAE@AAV12@@Z)
DNAStorage.obj : error LNK2019: unresolved external symbol "__declspec(dllimport
) public: void __thiscall std::basic_ostream<char,struct std::char_traits<char>
>::_Osfx(void)" (__imp_?_Osfx@?$basic_ostream@DU?$char_traits@D@std@@@std@@QAEXX
Z) referenced in function "public: __thiscall std::basic_ostream<char,struct std
::char_traits<char> >::sentry::~sentry(void)" (??1sentry@?$basic_ostream@DU?$cha
r_traits@D@std@@@std@@QAE@XZ)
DNAStorage.obj : error LNK2019: unresolved external symbol "__declspec(dllimport
) public: void __thiscall std::basic_streambuf<char,struct std::char_traits<char
> >::_Lock(void)" (__imp_?_Lock@?$basic_streambuf@DU?$char_traits@D@std@@@std@@Q
AEXXZ) referenced in function "public: __thiscall std::basic_ostream<char,struct
 std::char_traits<char> >::_Sentry_base::_Sentry_base(class std::basic_ostream<c
har,struct std::char_traits<char> > &)" (??0_Sentry_base@?$basic_ostream@DU?$cha
r_traits@D@std@@@std@@QAE@AAV12@@Z)
DNAStorage.obj : error LNK2019: unresolved external symbol "__declspec(dllimport
) public: void __thiscall std::basic_streambuf<char,struct std::char_traits<char
> >::_Unlock(void)" (__imp_?_Unlock@?$basic_streambuf@DU?$char_traits@D@std@@@st
d@@QAEXXZ) referenced in function "public: __thiscall std::basic_ostream<char,st
ruct std::char_traits<char> >::_Sentry_base::~_Sentry_base(void)" (??1_Sentry_ba
se@?$basic_ostream@DU?$char_traits@D@std@@@std@@QAE@XZ)
config_dna.obj : error LNK2019: unresolved external symbol "__declspec(dllimport
) public: class NotifyCategory * __thiscall NotifyCategoryProxy<class NotifyCate
goryGetCategory_dna>::init(void)" (__imp_?init@?$NotifyCategoryProxy@VNotifyCate
goryGetCategory_dna@@@@QAEPAVNotifyCategory@@XZ) referenced in function "public:
 __thiscall NotifyCategoryGetCategory_dna::NotifyCategoryGetCategory_dna(void)"
(??0NotifyCategoryGetCategory_dna@@QAE@XZ)
built/libpandadna.pyd : fatal error LNK1120: 15 unresolved externals

Are you defining the BUILDING_PANDASKEL preprocessor symbol while compiling your library?

Oh right, I should’ve known I was forgetting something. By the way, is there any problems if I do not use EXPCL_DNA macro in my classes?

Yes. They are set by panda/src/pandabase/pandasymbols.h, and depending on the state of BUILDING_DNA, they should be set to the right DLL export/import settings when compiling for Windows.