Hello, please teach how to link a library to a project in Visual Studio. In all textbooks I found only #include directives, but this method does not help me ...

  • In the project settings, specify the correct .lib file for the release version and the release version, respectively. - Costantino Rupert
  • Right-clicking on the project icon in Solution Explorer is the last of Properties - Configuration Properties - Linker - Input - Additional Dependencies. .lib files should be put in \ Visual Studio 2012 \ VC \ lib .h in \ Visual Studio 2012 \ VC \ include - igumnov
  • @igumnov Then your project will not be collected from anyone but you. It is more correct to put the libraries and their headers in any folder in the project and add these paths to the Additional Library Directories and Additional Include Directories . - Costantino Rupert
  • @ Kotik_khohet_kushat Anyway, you have to copy them with the project if you suddenly need to transfer to another computer. - igumnov
  • one
    @ Kotik_khohet_kushat If more than one person works, then of course your option is better. And then some guy just wants to assemble a BOX2D at home. @Alerr Configuration Properties - C / C ++ Additional Include Directories. Configuration Properties - Linker - General - Additional Library Directories second option that offers @ Kotik - igumnov

1 answer 1

Option one. No .lib files. Create a directory in the project directory, transfer the raw files of your library there, and later add them as ExistingItems in the project itself.

Check paths in headers / cpp files, etc. - it may very well be that these files were not supposed to be stored in a single directory, so keep the original directory hierarchy during the transfer.

Compile.

Option two - need .lib. As rightly noted in the comments - for each version of the assembly you need your own version of the library. There are only headers.

Regarding what you have in the comments, you need to specify the following key / NODEFAULTLIB: in the project settings / Linker / CommandLine: (library name from the Errors window). But it may not help. See the whole message - often errors are obtained due to incompatibility of some settings when building a library and building a project, for example, slightly less than everything from the "CodeGeneration" tab))

Kst., Here about dynamic, but interesting))