Hi all,
I'm porting Linux C code to NDK. I was used sysinfo function in my
code.
When i compile the souce code , i get the following error.
undefined reference to `sysinfo'
collect2: ld returned 1 exit status
But still the problem is happen.
herewtih i attached the sample code.
Please guide me, how to resolve this issue.
=======Compile Error========
make APP=sysinfo
Android NDK: Building for application 'sysinfo'
Compile thumb : sysinfo <= apps/sysinfo/project/jni/sysinfo.c
Executable : sysinfo
out/apps/sysinfo/armeabi/objs/sysinfo/sysinfo.o: In function `main':
../android-ndk-r3/apps/sysinfo/project/jni/sysinfo.c:46: undefined
reference to `sysinfo'
collect2: ld returned 1 exit status
make: *** [out/apps/sysinfo/armeabi/sysinfo] Error 1
=========================
======Source Code: sysinfo.c =========
#include <sys/sysinfo.h>
#include <stdio.h>
int main() {
int days, hours, mins;
struct sysinfo sys_info;
if(sysinfo(&sys_info) != 0)
perror("sysinfo");
// Uptime
days = sys_info.uptime / 86400;
hours = (sys_info.uptime / 3600) - (days * 24);
mins = (sys_info.uptime / 60) - (days * 1440) - (hours * 60);
printf("Uptime: %ddays, %dhours, %dminutes, %ldseconds\n",
days, hours, mins, sys_info.uptime % 60);
// Load Averages for 1,5 and 15 minutes
printf("Load Avgs: 1min(%ld) 5min(%ld) 15min(%ld)\n",
sys_info.loads[0], sys_info.loads[1], sys_info.loads[2]);
// Total and free ram.
printf("Total Ram: %ldk\tFree: %ldk\n", sys_info.totalram / 1024,
sys_info.freeram / 1024);
// Shared and buffered ram.
printf("Shared Ram: %ldk\n", sys_info.sharedram / 1024);
printf("Buffered Ram: %ldk\n", sys_info.bufferram / 1024);
// Swap space
printf("Total Swap: %ldk\tFree: %ldk\n", sys_info.totalswap / 1024,
sys_info.freeswap / 1024);
// Number of processes currently running.
printf("Number of processes: %d\n", sys_info.procs);
return 0;
}
========================
Thanks
--
You received this message because you are subscribed to the Google Groups "android-ndk" group.
To post to this group, send email to
andro...@googlegroups.com.
To unsubscribe from this group, send email to
android-ndk...@googlegroups.com.
For more options, visit this group at
http://groups.google.com/group/android-ndk?hl=en.