I am facing the error as in below,
Undefined first referenced
symbol in file
void bcMwMrsh::cppListFromWire<CSSCODERec*>(void*&, RWTValSlist<CSSCODERec*, std::allocator<CSSCODERec*> >&, AISObject* (*)()) /app/sdasup/home/mhp/source/develop/sd/lib/libsdHostSupport.so
ld: fatal: symbol referencing error
Under bc/include/bcMwMrsh.h cppListFromWire defined as below, Please note I have declared and defined the cppListFromWire in .h
typedef AbcObject *(*factory)()
namespace bcMwMrsh
{
template<typename listT>
void cppListFromWire(void *&src,RWTValSlist<listT> &dest, factory);
}
template<typename listT>
void bcMwMrsh::cppListFromWire(void *&src, RWTValSlist<listT> &list, factory factoryFunc)
{LOG (LM_MARSHAL_COM, (" bcMwMrsh::cppAbcListFromWire()...\n"));
int nItems = 0;
ptrdiff_t* pstart = (ptrdiff_t*) src;
bcMwMrsh::cppIntFromWire(src, &nItems);
for (int i = 0; i < nItems; i++)
{
AbcObject *elem = factoryFunc();
assert (elem); // improper assert; should cause exception - KD
elem->fromWire(src);
list.append(elem);
}
LOG (LM_MARSHAL_COM, (" bcMwMrsh::cppAbcListFromWire(): length %i\n", ptrdiff_t((ptrdiff_t*)src - pstart)));
}
and under "wv/include/cppmarsh.h" cppListFromWire been defined as in below,
typedef AISObject *(*factorywv)();
namespace bcMwMrsh
{
template<typename listT>
void cppListFromWire(void *&src,RWTValSlist<listT> &dest, factorywv);
}
template<typename listT>
void cppListFromWire(void *&src,RWTValSlist<listT> &list, factorywv factoryFunc)
{
LOG (LM_MARSHAL_COM, (" cppmarsh::cppListFromWire()...\n"));
ptrdiff_t* pstart = (ptrdiff_t*) src;
short nItems=0;
bcMwMrsh::cppShortFromWire(src, &nItems);
for (int i=0; i < nItems; i++)
{
AISObject *elem = factoryFunc();
assert(elem); // improper assert; should cause exception - KD
elem->fromWire(src, 0);
list.append(elem);
}
LOG (LM_MARSHAL_COM, (" cppmarsh::cppListFromWire(): length %i\n",
ptrdiff_t((ptrdiff_t*)src - pstart)));
}
And the .so (/app/sdasup/home/mhp/source/develop/sd/lib/libsdHostSupport.so) path where the error is pointing out has cppListFromWire used at two files as in below,
under sd/sdHostSupport/csscode.cpp
#include "csscode.h"
#include "cppmarsh.h"
int CSSCODERecList::fromWire(void *&buf, long bufLen)
{
bcMwMrsh::cppListFromWire(buf, contents, CSSCODERec::AISFactory);
return 0;
}
and under sd/sdHostSupport/__cppmarsh.cpp
#include "cppmarsh.h"
void cppIntFromWire(void *&src, int *dest)
{
assert(sizeof(int)==4);
*dest=0;
#ifndef LITTLE_ENDIAN //NT Port
*((char*)dest+3)=*((char*)src);
*((char*)dest+2)=*((char*)src+1);
#else
*((char*)dest)=*((char*)src);
*((char*)dest+1)=*((char*)src+1);
#endif
(char*&)src+=2;
}
template<typename listT>
void cppListFromWire(void *&src,RWTValSlist<listT> &list, factorywv factoryFunc)
{
int nItems = 0;
cppIntFromWire(src, &nItems);
for (int i = 0; i < nItems; i++)
{
AISObject *elem = factoryFunc();
assert(elem); // improper assert; should cause exception - KD
elem->fromWire(src, 0);
list.append(elem);
}
}
Is this something related to function-overloading, as I can see cppListFromWire defined has one parameter with different return type? However I see that is falling under overloading rules. Anything that differs here please let me know.
I tried including signature in both the files didn't work. Also tried including absolute header paths didn't work. One thing that worked was when I commented out below line form the file sd/sdHostSupport/csscode.cpp but that vague thing one can do.
bcMwMrsh::cppListFromWire(buf, contents, CSSCODERec::AISFactory);
I am unable to figure out what's the problem and how to resolve that. Been stuck for about 2 weeks now. Any kind of help/suggestions/inputs are greatly appreciated.