LinuxQuestions.org
Help answer threads with 0 replies.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 02-27-2005, 11:51 PM   #1
RedFox
LQ Newbie
 
Registered: Feb 2005
Posts: 2

Rep: Reputation: 0
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?
 
Old 02-28-2005, 12:04 AM   #2
crabboy
Senior Member
 
Registered: Feb 2001
Location: Atlanta, GA
Distribution: Slackware
Posts: 1,821

Rep: Reputation: 121Reputation: 121
did you try:
Code:
cc myprog.c -lapm
libapm.a is under /usr/lib
 
Old 02-28-2005, 12:22 AM   #3
RedFox
LQ Newbie
 
Registered: Feb 2005
Posts: 2

Original Poster
Rep: Reputation: 0
I guess compiling the library in would help. 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
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
apm -s...almost buldir Linux - Laptop and Netbook 0 11-28-2004 03:46 AM
Dilema: How to compile APM module without enough space on HD ranceramos Linux - Laptop and Netbook 0 10-23-2004 02:53 AM
apm vs. acpi ? (modprobe: FATAL: Error inserting apm) OneManArmy Linux - Laptop and Netbook 0 05-12-2004 04:39 PM
apm snu Linux - Hardware 0 12-06-2003 07:32 AM
Apm kcbnac Linux - Newbie 1 04-11-2003 11:06 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 05:19 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration