Q:

How to obtain the path of a library

I can compile my executable file by follow commands
g++ -c main.cpp
g++ main.o -o my_exe -lmy

I do not need to specify the path of the libmy.a using -L path during link. 
The libmy.a can automatically find by system. 
Now I want to find the path of libmy.a but I have no idea where it is. 
How can I obtain the full path of libmy.a?  

A:

Instead of:-
g++ main.o -o my_exe -lmy

link your program with:-
g++ main.o -o my_exe -lmy -Wl,-trace

This will make g++ pass the diagnostic option -trace to the linker.  The linker
will print the pathname by which it locates every object file, shared library or static libary that it inputs.  Inspect the output and you will find the full pathname of libmy.a

