Linking against NuGet Libraries in Visual Studio 2013

John Snow picture John Snow · Feb 5, 2014 · Viewed 7.7k times · Source

Hi: In Visual Studio 2012 Professional, Update 4, I can create a new OpenGL project pretty easily by creating a new Visual C++ project (using the blank template) and going into the NuGet Package Manager Console and typing:

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

To grab the libraries for freeglut, glew, and glm (a header-only math library.)

I can then create a simple example utilizing 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 further configuration, I can hit the big green build button and everything compiles, links, and runs (finding the redistributable .dlls in the NuGet packages) and works fine.

In Visual Studio 2013, the same approach doesn't work: VS2013 complains that it cannot find freeglut.lib:

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

I can get the project to compile if I manually edit the Library path and copy the DLLs to the build output directory, but this seems severely less convenient.

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

Is this a per-package difficulty, or did VS2013 change something about how Visual Studio handles NuGet packages?

Answer

dodowell picture dodowell · Oct 16, 2014

I have same problem, after Install-Package freeglut

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

It works