Its a long time since I've used C but now I'm trying to compile a short script that gets server-stats from the Apache-Portable-Runtime (APR).
Header files located at /usr/include/apr-1/apr*.h and libs are located at /usr/lib64/libapr-1.*
Source files can be found on the official APR site http://apr.apache.org/docs/apr/1.3/files.html.
/* test.c */
#include <stdio.h>
#include <stdlib.h>
#include <apr_general.h>
#include <apr_time.h>
int main(int argc, const char *argv[])
{
apr_time_t t;
t = apr_time_now();
printf("The current time: %" APR_TIME_T_FMT "[us]\n", t);
return 0;
}
When I try and compile I get the following error (which I believe is a linking issue):
~> gcc -Wall $(apr-1-config --cflags --cppflags --includes --link-ld) test.c -o test.bin /tmp/cc4DYD2W.o: In function `main': test.c:(.text+0x10): undefined reference to `apr_time_now' collect2: ld returned 1 exit status
My environment is gentoo:
~> uname -a Linux alister 2.6.32.21-grsec-gt-r2 #1 SMP Tue Sep 7 23:54:49 PDT 2010\ x86_64 Intel(R) Xeon(R) CPU L5640 @ 2.27GHz GenuineIntel GNU/Linux` ~> gcc -v gcc version 4.3.4 (Gentoo 4.3.4 p1.1, pie-10.1.5) ~> emerge --search "%@^dev-lib.*apr" * dev-libs/apr Latest version installed: 1.3.9 * dev-libs/apr-util Latest version installed: 1.3.9
Does anyone with more experience with C on Linux have any suggestions for me to get this working?
As always thanks in advance.
gcc -v
output if someone thinks that will help. – CoffeeMonster Nov 5 '10 at 21:15