You need to ensure that you specify the library path during linking when you compile your .c file:
gcc -I/usr/local/include xxx.c -o xxx -L/usr/local/lib -Wl,-R/usr/local/lib
The -Wl,-R
part tells the resulting binary to also look for the library
in /usr/local/lib
at runtime before trying to use the one in /usr/lib/
.