在Visual Studio 2010中链接库 [英] Linking Library In Visual Studio 2010

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

问题描述

当我无聊时,我正在做一些研究,我发现这个glut32.dll,glut32.h和glut32.lib文件,应该包含几个不同的函数定义(如果我没有错误)这个源代码使用的函数。

I'm doing some research on the side when I'm bored and I found this glut32.dll, glut32.h and glut32.lib files that should hold the function definitions (If I'm not mistaken) of several different functions that this source code uses.

我正在使用Visual Studio 2010,因此我必须使用项目的属性手动添加.lib文件。所以...

I'm using Visual Studio 2010 so I have to add .lib files manually using the project's properties. So...


  • 我转到项目/属性/配置。属性/ VC ++目录,并添加我的头文件和.lib / .dll文件到包含,引用,源和库属性。

  • I go to the Project/Properties/Config. Properties/VC++ Directories and add where my header files and .lib/.dll files are to the Include, Reference, Source and Library properties.

然后我在配置中进入C / C ++。 Prop。菜单中,进入常规选项卡,并将我的.h / .lib / .dll文件的位置添加到其他包括目录。

I then go into C/C++ in the Config. Prop. menu, into the General tab, and add the locations of my .h/.lib/.dll files to the Additonal Include Directories.

返回到C / C ++目录,进入高级选项卡,让代码编译为C代码(在C和C ++代码之间改变到底)。

Go back into the C/C++ directory, to the Advanced tab and tell the code to compile as C code (changing this between C and C++ code does nothing in the end).

然后,在C / C ++选项卡中, Prop.s选项卡,我进入链接器选项卡。在这里,我去附加库目录,并添加我的.lib和.dll文件的位置。

Then, out of the C/C++ tab, into the Config. Prop.s tab, I enter the Linker tab. Here, I go to the "Additional Library Directories" and add where my .lib and .dll files are.

然后进入输入选项卡,在添加依赖项选项卡中以.lib文件的名称写入。

Then into the Input tab where I write in the name of the .lib file in the Addition Dependencies tab. I've hit apply after every change and click apply/ok this time.

我通过代码进行构建,得到此错误:

I go to build by code and get this error:

1>------ Build started: Project: simplVRML, Configuration: Debug Win32 ------
1>Build started 3/30/2011 7:46:45 AM.
1>InitializeBuildStatus:
1> Touching "Debug\simplVRML.unsuccessfulbuild".
1>ClCompile:
1> All outputs are up-to-date.
1>ManifestResourceCompile:
1> All outputs are up-to-date.
1>object.obj : error LNK2019: unresolved external symbol _arLoadPatt referenced in function _read_VRMLdata
1>object.obj : error LNK2019: unresolved external symbol _arVrmlLoadFile referenced in function _read_VRMLdata
1>simpleVRML.obj : error LNK2019: unresolved external symbol _arVrmlDraw referenced in function _main
1>simpleVRML.obj : error LNK2019: unresolved external symbol _arUtilTimerReset referenced in function _main
1>simpleVRML.obj : error LNK2019: unresolved external symbol _arglSetupForCurrentContext referenced in function _main
1>simpleVRML.obj : error LNK2019: unresolved external symbol __imp__arVideoCapStart referenced in function _setupCamera
1>simpleVRML.obj : error LNK2019: unresolved external symbol _arInitCparam referenced in function _setupCamera
1>simpleVRML.obj : error LNK2019: unresolved external symbol _arParamDisp referenced in function _setupCamera
1>simpleVRML.obj : error LNK2019: unresolved external symbol _arParamChangeSize referenced in function _setupCamera
1>simpleVRML.obj : error LNK2019: unresolved external symbol _arParamLoad referenced in function _setupCamera
1>simpleVRML.obj : error LNK2019: unresolved external symbol __imp__arVideoInqSize referenced in function _setupCamera
1>simpleVRML.obj : error LNK2019: unresolved external symbol __imp__arVideoOpen referenced in function _setupCamera
1>simpleVRML.obj : error LNK2001: unresolved external symbol _arMatchingPCAMode
1>simpleVRML.obj : error LNK2001: unresolved external symbol _arTemplateMatchingMode
1>simpleVRML.obj : error LNK2019: unresolved external symbol _arglTexmapModeGet referenced in function _debugReportMode
1>simpleVRML.obj : error LNK2019: unresolved external symbol _arglDrawModeGet referenced in function _debugReportMode
1>simpleVRML.obj : error LNK2001: unresolved external symbol _arImageProcMode
1>simpleVRML.obj : error LNK2001: unresolved external symbol _arFittingMode
1>simpleVRML.obj : error LNK2019: unresolved external symbol __imp__arVideoClose referenced in function _Quit
1>simpleVRML.obj : error LNK2019: unresolved external symbol __imp__arVideoCapStop referenced in function _Quit
1>simpleVRML.obj : error LNK2019: unresolved external symbol _arglCleanup referenced in function _Quit
1>simpleVRML.obj : error LNK2019: unresolved external symbol __imp__arVideoDispOption referenced in function _Keyboard
1>simpleVRML.obj : error LNK2019: unresolved external symbol _arUtilTimer referenced in function _Keyboard
1>simpleVRML.obj : error LNK2019: unresolved external symbol _arglTexmapModeSet referenced in function _Keyboard
1>simpleVRML.obj : error LNK2019: unresolved external symbol _arglDrawModeSet referenced in function _Keyboard
1>simpleVRML.obj : error LNK2019: unresolved external symbol _arGetTransMatCont referenced in function _Idle
1>simpleVRML.obj : error LNK2019: unresolved external symbol _arGetTransMat referenced in function _Idle
1>simpleVRML.obj : error LNK2019: unresolved external symbol _arDetectMarker referenced in function _Idle
1>simpleVRML.obj : error LNK2019: unresolved external symbol __imp__arVideoGetImage referenced in function _Idle
1>simpleVRML.obj : error LNK2019: unresolved external symbol _arVrmlTimerUpdate referenced in function _Idle
1>simpleVRML.obj : error LNK2019: unresolved external symbol _arglCameraViewRH referenced in function _Display
1>simpleVRML.obj : error LNK2019: unresolved external symbol _arglCameraFrustumRH referenced in function _Display
1>simpleVRML.obj : error LNK2019: unresolved external symbol __imp__arVideoCapNext referenced in function _Display
1>simpleVRML.obj : error LNK2019: unresolved external symbol _arglDispImage referenced in function _Display
1>C:\Users\*\Desktop\AltReality\Pwork\simplVRML\Debug\simplVRML.exe : fatal error LNK1120: 34 unresolved externals
1>
1>Build FAILED.
1>
1>Time Elapsed 00:00:00.81
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========

我可以确认问题是我如何链接库,肯定做错了,因为当我尝试链接其他库到其他项目的结果是一样的。我在网上看过,我试过几个教程,但没有成功 - 有人可以告诉我我做错了什么?

I can confirm the problem is how I'm linking the library, I'm definitely doing something wrong because when I try to link other libraries to other projects the result is the same. I've looked online and I've tried several tutorials, but to no avail- could somebody please tell me what I'm doing wrong?

推荐答案

正如上一篇文章所述,确保.dll / .lib文件与您正在构建的.exe / .dll在同一目录中,然后转到项目的解决方案资源管理器,右 - 点击项目名称,选择添加 - >现有项目...,然后选择要包括的.dll / .lib文件。

As the previous post says, make sure your .dll/.lib file(s) are in the same directory as the .exe/.dll you are building and then go to your project's "Solution Explorer", right-click on the project name, choose "Add" -> "Existing Item...", then select the .dll/.lib file you want to include.

您应该会在解决方案资源管理器中的源文件部分下面列出.dll / .lib文件。我看到相同的错误,直到我执行我刚才描述的步骤。

You should now see the .dll/.lib file listed below the "Source Files" section in the "Solution Explorer". I was seeing the same errors until I performed the steps I just described.

此外,确保您的头文件包含在项目中,并引用源文件。

Also, make sure that your header file(s) are included in the project and referenced in the source files appropriately.

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

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