Having trouble using libstatgrab — I receive the following error at compile time:
"libstatgrabTest.cpp:16: undefined reference to sg_get_process_stats"
I’m guessing it is because I need to include it’s .so files at the linking state — although I’m not sure. As you can see below, I am currently including the statgrab.h header file. I performed configured && make && make install for the library.
If I search for libstatgrab*, I come across the following:
./usr/local/lib/libstatgrab.so.6.2.3
./usr/local/lib/libstatgrab.la
./usr/local/lib/libstatgrab.so.6
./usr/local/lib/libstatgrab.a
./usr/local/lib/libstatgrab.so.6.2.2
./usr/local/lib/libstatgrab.so
./usr/local/lib/pkgconfig/libstatgrab.pc
Another search for statgrab* returns the following (relevant items only):
./usr/local/bin/statgrab
./usr/local/include/statgrab_deprecated.h
./usr/local/include/statgrab.h
At compilation, I run: g++ -g -c libstatgrabTest.cpp
At linking, I run: g++ -L/usr/local/lib libstatgrab.o -o libstatgrabTest
Any idea what I am doing wrong? The code within libstagrabTest.cpp is shown below:
// external libraries
#include <statgrab.h> // libstatgrab (http://www.i-scream.org/libstatgrab/)
// namespace
using namespace std;
int main(void) {
// try to initalize libstatgrab
int * entries;
sg_process_stats * systemStats = sg_get_process_stats(entries);
// return
return 0;
}
should be (tested with your code snipper on Ubuntu Natty):
or, to link statically:
Tested both on my box, with your exact source.