Issue with using Apache APR Library in C program

449 Views Asked by At

I am trying to build APR library from source and use the library in my C code. I am using Ubuntu OS. I followed the steps mentioned in APR website to build the library.

./configure
sudo make
sudo make install

In the make install output, I got the library installed path as shown below.

Libraries have been installed in:
   /usr/local/apr/lib

The given path has the following files.

adhithiyan@ubuntu:/usr/local/apr/lib$ ls -lrt
total 3768
-rwxr-xr-x 1 root root 1343392 Jan  8 14:48 libapr-1.so.0.7.0
lrwxrwxrwx 1 root root      17 Jan  8 14:48 libapr-1.so.0 -> libapr-1.so.0.7.0
lrwxrwxrwx 1 root root      17 Jan  8 14:48 libapr-1.so -> libapr-1.so.0.7.0
-rwxr-xr-x 1 root root     964 Jan  8 14:48 libapr-1.la
-rw-r--r-- 1 root root 2492102 Jan  8 14:48 libapr-1.a
-rw-r--r-- 1 root root   10883 Jan  8 14:48 apr.exp
drwxr-xr-x 2 root root    4096 Jan  8 14:48 pkgconfig

Then, I created a simple c program as shown below. I am just trying to include a header from the library.

#include <stdio.h>
#include "apr_strings.h"

int main()
{       
    printf("Hello World\n");
    
}

When i try to compile. I am getting the below error.

adhithiyan@ubuntu:~/learning_c$ gcc -L/usr/local/apr/lib stringcompare.c -o test
stringcompare.c:2:10: fatal error: apr_strings.h: No such file or directory
    2 | #include "apr_strings.h"
      |          ^~~~~~~~~~~~~~~
compilation terminated.

I tried setting LD_LIBRARY_PATH as well but I got the same error. I am not sure whether I have missed something in build or in linking the library. Any help is appreciated.

0

There are 0 best solutions below