16

I am trying to build a project with another project. There are a lot of libs in there and I am not sure where the required unreferenced symbols are present.

Is there a way I can include all the .lib files while compiling?

I have given the lib directory as an additional input to the linker, yet it asks for individual .lib files to be included. Is there an option to say include all .libs in this folder?

Dr1Ku
  • 2,875
  • 3
  • 47
  • 56
AMM
  • 17,130
  • 24
  • 65
  • 77

5 Answers5

21

bigD's answer is right.

The place you would actually do this, in VS 2012 at least, is by right-clicking on the project, then going:

Properties > Configuration Properties > Linker > Command Line > Additional Options

In that box, you would just type:

"[libFolder]\*.lib"

You can have multiple locations by separating locations with a space, like so:

"[libFolder1]\*.lib" "[libFolder2]\*.lib"
Joshua Maiche
  • 295
  • 2
  • 6
  • This was a lot easier than adding them all individually. Not sure if I included libs that I don't need however. +1 for saving me some time while hacking around. – Landon Poch Nov 16 '14 at 05:45
  • 1
    You can also add /VERBOSE:UNUSEDLIBS to the line to get any libraries that have not been used. – Joshua Maiche Nov 18 '14 at 23:05
6

You should just be able to write "someFolder/*.lib" where you have to specify the libraries to link against

ds-bos-msk
  • 780
  • 9
  • 13
3

AFAIK there is no way to do that: your options are to

  • include each lib in the linker->Input->Additional Dependencies

  • include libs via pragma directive in the source file i.e. add

pragma comment(lib, "some_lib.lib" )

  • if the projects are part of the solution, you can select them as "Project Dependencies"

The easiest way to do it is to use the pragma since you only have to do it once for both debug and release. For example, you could do a directory listing of your lib directory and then copy and past the remainder of the directive into your source file(s).

Further, to get a symbol listing of a static library, you can run the dumpbin tool on the lib files (AFAIR with the /ALL option).

Community
  • 1
  • 1
Ralf
  • 9,405
  • 2
  • 28
  • 46
  • Has there been a change in recent versions of Visual Studio? Moreover, shouldn't it possible to write a pre-build script to scan the folder? – danijar Mar 23 '14 at 10:00
  • I'm using VS2015, and I was able to go into Linker->Input->Additional Dependencies and add [folder]\*.lib and have it work for me today. – RomSteady Sep 02 '15 at 22:48
1

This will output a file will all .lib files listed. You can copy and paste this or modify it according to your needs.

Save as a batch.

for %%f in (*.lib) DO echo|set /p=%%~f >> alllibs.txt 
0

Though you are in Visual Studio, if you go with command line, you can put all the libs in a linker response file and reference it as a standalone option with a @ during link phase.

Unfortunately, according the above link,

This linker option is not available from the Visual Studio development environment.

smwikipedia
  • 61,609
  • 92
  • 309
  • 482