LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   can't compile using apm.h (https://www.linuxquestions.org/questions/programming-9/cant-compile-using-apm-h-295719/)

RedFox 02-27-2005 11:51 PM

can't compile using apm.h
 
Hi all, i'm attempting to make a program to monitor and log my battery power (don't ask). I looked first at shell scripts, but I can't find any working shell commands that will report power (apm just says kernel doesn't support APM, acpid says it's busy, etc).

Therefore i've gone to a c program, because i know those have access to apm somehow (I have the battstat applet running, and it reports power just fine). problem there is, I can't compile anything that uses apm.h, the linker doesn't seem to find apm_read(). I've even gone thru apm.h itself and it does list that particular function.

Here's an excerpt of my test program:
Code:

#include <stdio.h>
#include <apm.h>
int main()
{
  apm_info apminfo;
  apm_read(&apminfo);
  int batt_life = apminfo.battery_percentage;
  printf("Battery life: %d%%", batt_life);
  return 0;
}

As you can see, very simple. I got inspiration for this from the source of battstat. As far as I can tell, apm_read() is supposed to fill the apm_info struct, so without that function, this approach is pretty useless.

Any ideas why this won't compile? or can you suggest any other routes to write a battery power logger?

crabboy 02-28-2005 12:04 AM

did you try:
Code:

cc myprog.c -lapm
libapm.a is under /usr/lib

RedFox 02-28-2005 12:22 AM

I guess compiling the library in would help. :rolleyes: I don't have a lot of experience using shared libs, can you tell?

it does at least compile that way. doesn't retrieve the info like i thought, but at least it compiles. thanks a million, i'll keep working on it from here


All times are GMT -5. The time now is 08:26 PM.