基本按照如下的步骤就可以编译和运行成功了(redhat AS 4 编译通过):
1. Install the apr in the system .
system: redhat AS 4
after building, the include files and libs will be installed in the /usr/local/apr/*
2.Compiling:
0). change "off64" into "long long" of the file /usr/local/apr/include/apr-1/apr.h
typedef off64 apr_off_t -> typedef long long apr_off_t
1). export LD_LIBRARY_PATH=/usr/local/apr/lib
2). -I/usr/local/apr/include/apr-1
3). -lapr-1
gcc -o test test.o -I. -I/usr/local/apr/include/apr-1 -L/usr/local/apr/lib/ -lapr-1
4). run it : -> ./test
附件: test.c
#include <apr.h>
#include <apr_general.h>
int main(int argc, const char * const * argv, const char * const *env)
{
apr_app_initialize(&argc, &argv, &env);
printf("test ok/n");
apr_terminate();
}
compliling:
gcc -c test.c -I/usr/local/apr/include/apr-1
gcc -o test test.c -I/usr/local/apr/include/apr-1 -L/usr/local/apr/lib -lapr-1
referrence: