在 Visual Studio 2013 中链接 NuGet 库 [英] Linking against NuGet Libraries in Visual Studio 2013

查看:99
本文介绍了在 Visual Studio 2013 中链接 NuGet 库的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好:在 Visual Studio 2012 Professional Update 4 中,我可以通过创建新的 Visual C++ 项目(使用空白模板)并进入 NuGet 包管理器控制台并输入:

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

获取 freeglut、glew 和 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[]) {
  ...
}

然后无需任何进一步的配置,我就可以点击绿色的大构建按钮,一切都会编译、链接和运行(在 NuGet 包中找到可再发行的 .dll)并且工作正常.

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.

在 Visual Studio 2013 中,同样的方法不起作用:VS2013 抱怨它找不到 freeglut.lib:

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

链接:致命错误 LNK1104:无法打开文件freeglut.lib"

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

如果我手动编辑库路径并将 DLL 复制到构建输出目录,我可以编译项目,但这似乎非常不方便.

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.

有趣的是,即使没有设置或更改任何内容,Visual Studio 似乎也足够聪明,可以知道寻找 freeglut.lib,但它似乎不知道在哪里可以找到它.

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.

这是每个包的问题,​​还是 VS2013 是否改变了 Visual Studio 处理 NuGet 包的方式?

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

推荐答案

我也有同样的问题,在 Install-Package freeglut 之后

I have same problem, after Install-Package freeglut

然后我尝试安装另一个包:Install-Package nupengl.core

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

有效

这篇关于在 Visual Studio 2013 中链接 NuGet 库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆