[AGENT++] linking error, msec.cpp:277: undefined reference to `Snmp_pp::msec::m_localtime_mutex'

Gens Michael.Gens at TU-Berlin.DE
Fri Jun 13 11:16:04 CEST 2014


Hello Jochen,

A complete rebuild did not change anything.

My try with snmp++ files resulted in:

Invoking: GCC C++ Linker
g++ -L/usr/local/include/ -L/usr/local/include/snmp_pp/ 
-L/usr/local/lib64 -L/usr/lib64/ -pthread -o "snmp++get" ./get_group.o 
./get_singleMIB.o ./help.o ./mainSnmp++get.o ./usage.o

./get_group.o: In function `get_system_group()':
.../eclipse/c/snmp++get/Debug/../get_group.cpp:28: undefined reference 
to `Snmp_pp::IpAddress::IpAddress(char const*)'
.../eclipse/c/snmp++get/Debug/../get_group.cpp:28: undefined reference 
to `Snmp_pp::CTarget::CTarget(Snmp_pp::Address const&)'
.../eclipse/c/snmp++get/Debug/../get_group.cpp:30: undefined reference 
to `Snmp_pp::Pdu::Pdu()'
.../eclipse/c/snmp++get/Debug/../get_group.cpp:33: undefined reference 
to `Snmp_pp::Snmp::Snmp(int&, unsigned short, bool)'
.../eclipse/c/snmp++get/Debug/../get_group.cpp:35: undefined reference 
to `Snmp_pp::Snmp::error_msg(int)'
.../eclipse/c/snmp++get/Debug/../get_group.cpp:39: undefined reference 
to `Snmp_pp::Oid::Oid(char const*, bool)'
.../eclipse/c/snmp++get/Debug/../get_group.cpp:40: undefined reference 
to `Snmp_pp::Oid::Oid(char const*, bool)'
.../eclipse/c/snmp++get/Debug/../get_group.cpp:41: undefined reference 
to `Snmp_pp::Oid::Oid(char const*, bool)'
.../eclipse/c/snmp++get/Debug/../get_group.cpp:42: undefined reference 
to `Snmp_pp::Oid::Oid(char const*, bool)'
.../eclipse/c/snmp++get/Debug/../get_group.cpp:43: undefined reference 
to `Snmp_pp::Oid::Oid(char const*, bool)'
./get_group.o:.../eclipse/c/snmp++get/Debug/../get_group.cpp:44: more 
undefined references to `Snmp_pp::Oid::Oid(char const*, bool)' follow

./get_group.o: In function `get_system_group()':
.../eclipse/c/snmp++get/Debug/../get_group.cpp:49: undefined reference 
to `Snmp_pp::Pdu::operator+=(Snmp_pp::Vb const&)'
.../eclipse/c/snmp++get/Debug/../get_group.cpp:52: undefined reference 
to `Snmp_pp::Snmp::get(Snmp_pp::Pdu&, Snmp_pp::SnmpTarget const&)'
.../eclipse/c/snmp++get/Debug/../get_group.cpp:53: undefined reference 
to `Snmp_pp::Snmp::error_msg(int)'
.../eclipse/c/snmp++get/Debug/../get_group.cpp:56: undefined reference 
to `Snmp_pp::Pdu::get_vblist(Snmp_pp::Vb*, int) const'
.../eclipse/c/snmp++get/Debug/../get_group.cpp:58: undefined reference 
to `Snmp_pp::Vb::get_printable_value() const'
.../eclipse/c/snmp++get/Debug/../get_group.cpp:57: undefined reference 
to `Snmp_pp::Snmp::~Snmp()'
.../eclipse/c/snmp++get/Debug/../get_group.cpp:33: undefined reference 
to `Snmp_pp::Pdu::~Pdu()'
.../eclipse/c/snmp++get/Debug/../get_group.cpp:33: undefined reference 
to `Snmp_pp::Snmp::~Snmp()'
.../eclipse/c/snmp++get/Debug/../get_group.cpp:30: undefined reference 
to `Snmp_pp::Pdu::~Pdu()'

./get_group.o: In function `Snmp_pp::Address::~Address()':
/usr/local/include/snmp_pp/address.h:162: undefined reference to `vtable 
for Snmp_pp::Address'
./get_group.o: In function `Snmp_pp::IpAddress::~IpAddress()':
/usr/local/include/snmp_pp/address.h:340: undefined reference to `vtable 
for Snmp_pp::IpAddress'
./get_group.o: In function `Snmp_pp::GenAddress::~GenAddress()':
/usr/local/include/snmp_pp/address.h:1012: undefined reference to 
`vtable for Snmp_pp::GenAddress'
./get_group.o: In function `Snmp_pp::SnmpTarget::~SnmpTarget()':
/usr/local/include/snmp_pp/target.h:125: undefined reference to `vtable 
for Snmp_pp::SnmpTarget'

./get_group.o: In function `Snmp_pp::CTarget::~CTarget()':
/usr/local/include/snmp_pp/target.h:327: undefined reference to `vtable 
for Snmp_pp::CTarget'
/usr/local/include/snmp_pp/target.h:327: undefined reference to 
`Snmp_pp::OctetStr::~OctetStr()'
/usr/local/include/snmp_pp/target.h:327: undefined reference to 
`Snmp_pp::OctetStr::~OctetStr()'
/usr/local/include/snmp_pp/target.h:327: undefined reference to 
`Snmp_pp::OctetStr::~OctetStr()'

./get_group.o: In function `Snmp_pp::Oid::Oid()':
/usr/local/include/snmp_pp/oid.h:104: undefined reference to `vtable for 
Snmp_pp::Oid'

./get_group.o: In function `Snmp_pp::Oid::~Oid()':
/usr/local/include/snmp_pp/oid.h:184: undefined reference to `vtable for 
Snmp_pp::Oid'

./get_group.o: In function `Snmp_pp::Vb::~Vb()':
/usr/local/include/snmp_pp/vb.h:118: undefined reference to 
`Snmp_pp::Vb::free_vb()'

./get_singleMIB.o: In function `get_singleMIB()':
.../eclipse/c/snmp++get/Debug/../get_singleMIB.cpp:18: undefined 
reference to `Snmp_pp::IpAddress::IpAddress(char const*)'
.../eclipse/c/snmp++get/Debug/../get_singleMIB.cpp:18: undefined 
reference to `Snmp_pp::CTarget::CTarget(Snmp_pp::Address const&)'
.../eclipse/c/snmp++get/Debug/../get_singleMIB.cpp:19: undefined 
reference to `Snmp_pp::Oid::Oid(char const*, bool)'
.../eclipse/c/snmp++get/Debug/../get_singleMIB.cpp:20: undefined 
reference to `Snmp_pp::Pdu::Pdu()'
.../eclipse/c/snmp++get/Debug/../get_singleMIB.cpp:23: undefined 
reference to `Snmp_pp::Snmp::Snmp(int&, unsigned short, bool)'
.../eclipse/c/snmp++get/Debug/../get_singleMIB.cpp:25: undefined 
reference to `Snmp_pp::Snmp::error_msg(int)'
.../eclipse/c/snmp++get/Debug/../get_singleMIB.cpp:29: undefined 
reference to `Snmp_pp::Pdu::operator+=(Snmp_pp::Vb const&)'
.../eclipse/c/snmp++get/Debug/../get_singleMIB.cpp:30: undefined 
reference to `Snmp_pp::Snmp::get(Snmp_pp::Pdu&, Snmp_pp::SnmpTarget const&)'
.../eclipse/c/snmp++get/Debug/../get_singleMIB.cpp:31: undefined 
reference to `Snmp_pp::Snmp::error_msg(int)'
.../eclipse/c/snmp++get/Debug/../get_singleMIB.cpp:33: undefined 
reference to `Snmp_pp::Pdu::get_vb(Snmp_pp::Vb&, int) const'
.../eclipse/c/snmp++get/Debug/../get_singleMIB.cpp:35: undefined 
reference to `Snmp_pp::Vb::get_printable_value() const'
.../eclipse/c/snmp++get/Debug/../get_singleMIB.cpp:35: undefined 
reference to `Snmp_pp::Snmp::~Snmp()'
.../eclipse/c/snmp++get/Debug/../get_singleMIB.cpp:23: undefined 
reference to `Snmp_pp::Pdu::~Pdu()'
.../eclipse/c/snmp++get/Debug/../get_singleMIB.cpp:23: undefined 
reference to `Snmp_pp::Snmp::~Snmp()'
.../eclipse/c/snmp++get/Debug/../get_singleMIB.cpp:20: undefined 
reference to `Snmp_pp::Pdu::~Pdu()'
./get_singleMIB.o: In function `Snmp_pp::Oid::Oid(Snmp_pp::Oid const&)':
/usr/local/include/snmp_pp/oid.h:137: undefined reference to `vtable for 
Snmp_pp::Oid'

./mainSnmp++get.o: In function `main':
.../eclipse/c/snmp++get/Debug/../mainSnmp++get.cpp:54: undefined 
reference to `Snmp_pp::UdpAddress::UdpAddress(char const*)'
.../eclipse/c/snmp++get/Debug/../mainSnmp++get.cpp:66: undefined 
reference to `Snmp_pp::OctetStr::OctetStr(char const*)'
.../eclipse/c/snmp++get/Debug/../mainSnmp++get.cpp:100: undefined 
reference to `Snmp_pp::OctetStr::operator=(char const*)'
.../eclipse/c/snmp++get/Debug/../mainSnmp++get.cpp:66: undefined 
reference to `Snmp_pp::OctetStr::~OctetStr()'
.../eclipse/c/snmp++get/Debug/../mainSnmp++get.cpp:66: undefined 
reference to `Snmp_pp::OctetStr::~OctetStr()'

./mainSnmp++get.o: In function `Snmp_pp::UdpAddress::~UdpAddress()':
/usr/local/include/snmp_pp/address.h:546: undefined reference to `vtable 
for Snmp_pp::UdpAddress'
collect2: error: ld returned 1 exit status
make: *** [snmp++get] Error 1

----------------------------------------------------------------------------------------------------

e.g. in
get_group.cpp I put

#include "libsnmp.h"

#include "snmp_pp/address.h"
#include "snmp_pp/target.h"
#include "snmp_pp/pdu.h"

#include "snmp_pp/snmp_pp.h"
...

------------------------------------------------------------------------------------------------------

content of  /usr/local/include/snmp_pp/  is

address.h    config_snmp_pp.h  eventlistholder.h  IPv6Utility.h 
mp_v3.h        octet.h    reentrant.h  snmperrs.h  timetick.h vb.h
asn1.h       counter.h         gauge.h            log.h msec.h         
oid_def.h  sha.h        snmpmsg.h   usm_v3.h
auth_priv.h  ctr64.h           idea.h             Makefile.am 
msgqueue.h     oid.h      smi.h        snmp_pp.h   uxsnmp.h
collect.h    eventlist.h       integer.h          md5.h notifyqueue.h  
pdu.h      smival.h     target.h    v3.h


Do I have to use / change more compiler / linker options ??


Best Rgds.


                    Michael


On 06/11/2014 10:42 PM, Jochen Katz wrote:
> Hello,
>
>> Unfortunately I still get the 'reference to
>> `Snmp_pp::msec::m_localtime_mutex' ' error.
> my best guess: Do a complete clean rebuild. If this does not help: Why
> do you use the snmp++ object files and not the library?
>
> Regards,
>    Jochen
> _______________________________________________
> AGENTPP mailing list
> AGENTPP at agentpp.org
> https://s16675406.onlinehome-server.info/mailman/listinfo/agentpp
>
>



More information about the AGENTPP mailing list