How to use SNMP++ functions in your own code

Hello all,
I built the SNMP++ library in a home directory as described in the README with the following commands:

autoreconf -i

Then added the following command:

sudo make install

To test the library I wrote the following minimal application up to the point of:

#include <libsnmp.h>
#include “/home/user/path/to/snmp+±3.4.10/include/snmp_pp/snmp_pp.h”

int main(int argc, char **argv) {
return 0;

(Please excuse the incorrect indentation. Unfortunately I don’t know how to do this correctly in Markdown. )

To build I try this as follows:

g++ myTest.cpp -o test

Unfortunately I get the following errors among others

myTest.cpp: In function ‘int main(int, char**)’:
myTest.cpp:7:3: error: ‘Snmp_pp’ has not been declared
myTest.cpp:8:3: error: ‘Snmp_pp’ has not been declared

My guess is, that I still need to tell the linker where to find the library. Unfortunately I don’t know the command for this.
I have also already tried it with -libsnmp. Unfortunately without success.

Thanks in advance and kind regards


there are surely some errors about missing includes. You should change the includes to

#include <libsnmp.h>
#include <snmp_pp/snmp_pp.h>

and then compile using g++ -I /home/user/path/to/snmp++-3.4.10/include/ -L /home/user/path/to/snmp++-3.4.10/lib64 -l snmp++ -o test (maybe lib64 has to be replaced with lib).

Kind regards,

1 Like

Hello jkatz,
thank you for your reply!
Your linker commands worked like a charm. I was able to build my test file and can start to work on my project now.

A small addition to the compile command: The filename was missing :wink:

g++ myTest.cpp -I /home/user/path/to/snmp+±3.4.10/include/ -L /home/user/path/to/snmp+±3.4.10/lib -l snmp++ -o test

For future people who read the answer here and want to know more about the different flags like “-L” or “-I” I can recommend the following page:

Kind regards