Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Linking against NuGet Libraries in Visual Studio 2013

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?

like image 864
John Snow Avatar asked Feb 05 '14 05:02

John Snow


2 Answers

I have same problem, after Install-Package freeglut

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

It works

like image 108
dodowell Avatar answered Sep 25 '22 18:09

dodowell


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

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

like image 40
Niclas Pallin Avatar answered Sep 23 '22 18:09

Niclas Pallin