I created a .so file and put it in the location /opt/lib and added this path to LD_LIBRARY_PATH now after this when I try to compile m
.so
/opt/lib
LD_LIBRARY_PATH
You need to add -L/opt/lib to tell ld to look there for shared objects.
-L/opt/lib
ld