Libraries and Other Linker Inputs

VisualGDB uses the standard Linux way of specifying libraries used by the projects that relies on 3 different parameters:

  1. Library directories. These are the directories where the GNU linker will search for libraries specified in "Library names". Locations like /usr/lib will be searched by default and do not need to be specified.
  2. Library names. This line contains short library names of libraries that should be linked with the project. The short library names do not contain the 'lib' prefix or the .a extension. E.g. in order to link with libpthread.a and libm.a this line should contain "pthread m".
  3. Additional linker inputs. This line can specify full paths to additional library or object files that should be linked with the project. This can be used to link against a specific version of a library, e.g. /usr/lib/i386-linux-gnu/libpthread.so.

It is recommended to specify libraries using the short names and directories, however if this causes problems (e.g. when using cross-compilation toolchains), it may be helpful to specify full paths to all necessary libraries using the "Additional Linker Inputs" line.

Diagnosing Linker Problems

You can force the linker to output a detailed log about the process of finding libraries. This can be accomplished by adding "-Wl,-verbose" to the linker command line (or using the "Verbose Mode" setting for MSBuild projects):

Building the project with the -Wl,-verbose flag will produce a detailed output about each linker's attempt to open a library:

1>attempt to open /usr/lib/gcc/i686-linux-gnu/4.8/../../../i386-linux-gnu/crt1.o succeeded
1>/usr/lib/gcc/i686-linux-gnu/4.8/../../../i386-linux-gnu/crt1.o
1>attempt to open /usr/lib/gcc/i686-linux-gnu/4.8/../../../i386-linux-gnu/crti.o succeeded
1>/usr/lib/gcc/i686-linux-gnu/4.8/../../../i386-linux-gnu/crti.o
1>attempt to open /usr/lib/gcc/i686-linux-gnu/4.8/crtbegin.o succeeded
1>/usr/lib/gcc/i686-linux-gnu/4.8/crtbegin.o
1>attempt to open VisualGDB/Debug/LibraryDemo.o succeeded
1>VisualGDB/Debug/LibraryDemo.o
1>attempt to open /usr/lib/gcc/i686-linux-gnu/4.8/libstdc++.so succeeded
1>-lstdc++ (/usr/lib/gcc/i686-linux-gnu/4.8/libstdc++.so)
1>attempt to open /usr/lib/gcc/i686-linux-gnu/4.8/libm.so failed
1>attempt to open /usr/lib/gcc/i686-linux-gnu/4.8/libm.a failed
1>attempt to open /usr/lib/gcc/i686-linux-gnu/4.8/../../../i386-linux-gnu/libm.so succeeded
1>-lm (/usr/lib/gcc/i686-linux-gnu/4.8/../../../i386-linux-gnu/libm.so)
1>attempt to open /usr/lib/gcc/i686-linux-gnu/4.8/libgcc_s.so succeeded
1>-lgcc_s (/usr/lib/gcc/i686-linux-gnu/4.8/libgcc_s.so)
1>attempt to open /usr/lib/gcc/i686-linux-gnu/4.8/libgcc.so failed
1>attempt to open /usr/lib/gcc/i686-linux-gnu/4.8/libgcc.a succeeded
1>attempt to open /usr/lib/gcc/i686-linux-gnu/4.8/libc.so failed
1>attempt to open /usr/lib/gcc/i686-linux-gnu/4.8/libc.a failed
1>attempt to open /usr/lib/gcc/i686-linux-gnu/4.8/../../../i386-linux-gnu/libc.so succeeded
1>opened script file /usr/lib/gcc/i686-linux-gnu/4.8/../../../i386-linux-gnu/libc.so
1>opened script file /usr/lib/gcc/i686-linux-gnu/4.8/../../../i386-linux-gnu/libc.so
1>attempt to open /lib/i386-linux-gnu/libc.so.6 succeeded
1>/lib/i386-linux-gnu/libc.so.6
1>attempt to open /usr/lib/i386-linux-gnu/libc_nonshared.a succeeded
1>(/usr/lib/i386-linux-gnu/libc_nonshared.a)elf-init.oS
1>attempt to open /lib/i386-linux-gnu/ld-linux.so.2 succeeded
1>/lib/i386-linux-gnu/ld-linux.so.2
1>attempt to open /usr/lib/gcc/i686-linux-gnu/4.8/libgcc_s.so succeeded
1>-lgcc_s (/usr/lib/gcc/i686-linux-gnu/4.8/libgcc_s.so)
1>attempt to open /usr/lib/gcc/i686-linux-gnu/4.8/libgcc.so failed
1>attempt to open /usr/lib/gcc/i686-linux-gnu/4.8/libgcc.a succeeded
1>attempt to open /usr/lib/gcc/i686-linux-gnu/4.8/crtend.o succeeded
1>/usr/lib/gcc/i686-linux-gnu/4.8/crtend.o
1>attempt to open /usr/lib/gcc/i686-linux-gnu/4.8/../../../i386-linux-gnu/crtn.o succeeded
1>/usr/lib/gcc/i686-linux-gnu/4.8/../../../i386-linux-gnu/crtn.o
1>libm.so.6 needed by /usr/lib/gcc/i686-linux-gnu/4.8/libstdc++.so
1>found libm.so at /usr/lib/gcc/i686-linux-gnu/4.8/../../../i386-linux-gnu/libm.so
1>ld-linux.so.2 needed by /usr/lib/gcc/i686-linux-gnu/4.8/libstdc++.so
1>found ld-linux.so.2 at /lib/i386-linux-gnu/ld-linux.so.2
1>libgcc_s.so.1 needed by /usr/lib/gcc/i686-linux-gnu/4.8/libstdc++.so
1>found libgcc_s.so at /usr/lib/gcc/i686-linux-gnu/4.8/libgcc_s.so