views:

197

answers:

3

How does one find out what is the lib that the above flag is referring to? How would I do it for some other one?

+2  A: 

The -l option takes the name of the library as the argument so in this case the library would be named libXi.a (or libXi.so or something similar). To find the library look in the standard library locations (/usr/lib, /lib, /usr/local/lib, etc.) available in your distribution. There may also be additional library directories specified using the -L option to the linker.

tvanfosson
A: 

If your program compiled successfully, or if you have another program which uses -lXi, then you can do:

ldd /path/to/that/program | grep libXi

For example:

$ ldd /usr/X11R6/bin/audacity | grep libXi
        libXinerama.so.1 => /usr/lib/libXinerama.so.1 (0x00007f53faaba000)
        libXi.so.6 => /usr/lib/libXi.so.6 (0x00007f53f8e2c000)

And that will most likely tell you where that library is. (It's not 100% because the build process could alter the search path but that's usually not likely for standard libraries like X11.)

From there, you can ask your distro which package has that file, if you care. For example on Ubuntu or a .deb-base distro:

$ dpkg --search /usr/lib/libXi.so.6
libxi6: /usr/lib/libXi.so.6

If you can't use LDD, then check your system's /etc/ld.so.conf which will indicate the search path for runtime shared library linking. (/lib/ and /usr/lib are included by default.)

Worst case, you could just find for it:

find / -regex '.*libXi\.\(a\|so\).*' 2> /dev/null
jhs
A: 
strace -f -e open gcc ... -lXi

Look for libXi in the output.

sigjuice