Compiling C programs with MySQL libraries

I have a program connect.c, when I compile it with
gcc -o connect connect.c -I/opt/mysql/include/mysql -L/opt/mysql/lib/mysql -lmysqlclient -lsocket -lm -lz
there’s no errors, but when I run ./connect I have this error:

Could not find library

This library is in my /opt/mysql/lib/mysql folder…
My version of MySQL is 3.23
Any idea?? Thanks.

At run time the OS will look in the LD_LIBRARY_PATH (no sure I got the name right) for share object.

Either modify the environement variable or move the share object in a directory specified in LD_LIBRARY_PATH.

I modified the LD_LIBRARY_PATH variable and it worked fine.