Linking NuGet Libraries in Visual Studio 2013

Hey. In Visual Studio 2012 Professional, Update 4, I can easily create a new OpenGL project by creating a new Visual C ++ project (using an empty template) and going to the NuGet package manager console and typing:

Install-Package freeglut Install-Package glew Install-Package glm 

To capture libraries for freeglut, glew, and glm (a math library for headers only.)

Then I can create a simple example using these libraries: ( full example )

 #include <GL/freeglut.h> #include <GL/glew.h> #include <glm/glm.hpp> int main(int argc, char *argv[]) { ... } 

And then, without any additional configuration, I can click the big green build button and compile everything, links and runs (find redistributable DLL files in NuGet packages) and it works fine.

In Visual Studio 2013, the same approach does not work: VS2013 complains that it cannot find freeglut.lib:

LINK: fatal error LNK1104: cannot open file 'freeglut.lib'

I can get the project for compilation by manually editing the library path and copying the DLLs into the assembly output file, but this seems less convenient.

Interestingly, even without installing or modifying anything, Visual Studio seems smart enough to know what to look for freeglut.lib, but it doesn't seem to know where to find it.

Is this a problem for each package, or has VS2013 changed something about how Visual Studio handles NuGet packages?

+6
source share
3 answers

I have the same problem after Install-Package freeglut

Then I try to install another package: Install-Package nupengl.core

Works

+10
source

What solved for linkerror for me was properties-> linker-> input-> additional dependencies and opengl32.lib was added.

You also need to make sure that freeglut.dll / glew32.dll / glfw3.dll are in the same folder as your executable file . This is what nupengl.core will install for you.

+3
source

For static connection:

 #define GLEW_STATIC #define FREEGLUT_STATIC #include <GL/glew.h> #include <GL/freeglut.h> 

Project-> Properties-> Configuration Properties-> Related Packages-> freeglut-> Communication (select static)

Do the same for reference packages-> glew

Now in Linker-> General-> Additional Library Directories:

$ (SolutionDir) \ packages \ freeglut.2.8.1.15 \ build \ native \ Lib \ V110 \ Win32 \ Debug \ static; $ (SolutionDir) \ packages \ glew.1.9.0.1 \ build \ native \ Lib \ V110 \ Win32 \ Debug \ static

Library options may change, and the path may change a little, but this is what works for me from May 14 to 2015.

EDIT: you still need to enable "glew.lib" in Linker-> Input-> Additional Dependencies, so worrying about link package settings seems pointless (it works for freeglut but not glew, and if you need glew to Additional Dependencies in anyway, it can also just add freeglut too).

For dynamic linking in the “Related packages” section, select “Dynamic linking” for freeglut and glew and add or replace each package library directory in the settings of additional library libraries and copy the DLLs from the distribution directory to your output directory projects, map the debug DLL to the Debug directory, and etc. Also, omit XXX_STATIC # defines :)

Dynamic settings are an assumption, but I know that static settings work.

0
source

All Articles