30

I've found the Additional Dependencies thing on Visual C++ 2010, but I can't seem to find any option of adding new .lib files when I go to . I need to add wsock32.lib to link with my file, how do I make it happen?

Thanks!

Zakum
  • 491
  • 1
  • 5
  • 6

3 Answers3

30

Add the wsock32.lib in the text field.

 Project Properties -> Linker -> Input -> Additional Dependencies.

When you click in the field, you get a ... button. Click on this button and add one library name per line. Alternatively you can write the names in the field. Separate all entries with space characters.

You can verify that it's on the command line in

 Project Properties -> Linker -> Command Line.
Max
  • 19,654
  • 13
  • 84
  • 122
harper
  • 13,345
  • 8
  • 56
  • 105
  • 1
    I said I've found the Additional Dependencies, but when I try to edit it, I don't have any "Add..." option. – Zakum Jun 01 '12 at 08:56
  • Click in the field "Additional Dependencies", you can edit it. – harper Jun 01 '12 at 14:39
  • what if i have to add a huge number of libs to my porject ? do i have to keep typing each name ? – Ace McCloud Apr 28 '15 at 19:27
  • Should be a question by its own. But: you can add them in differemt ways. 1) write the names to a text file, copy&paste 2) create a property sheet file and edit it outside VS, and reload the project. 3) Consider "#pragma comment(lib). – harper Apr 28 '15 at 19:38
6

Here is a GUI way to add a LIB file to your Visual Studio project in C and C++ Languages (for those of us who like to mouse-around like me). I did this in Visual Studio 2012. But I think it works in previous versions, as well.

  1. Find the LIB or other file you want to add to your project in Windows Explorer. Drag the LIB file from Windows Explorer onto Visual Studio's Solution Explorer, to the project to which you wish to add the LIB file. Now, you will see the file listed in Solution Explorer.

That's it! Just one step! You will not see the file in "Project Properties -> Linker -> Input -> Additional Dependencies." However, it is there hidden in the macro %(AdditionalDependencies).

Indinfer
  • 915
  • 9
  • 6
2

edit Additional Dependencies and puts wsock32.lib in it.

and also add the path of lib in Link->general-> additional library directories

RolandXu
  • 3,566
  • 2
  • 17
  • 23
  • Adding the path can be necessary If you add a custom or third party library. In the case of wsock32.lib it's not necessary since that's in the compiler library folder. – harper Sep 01 '18 at 13:38