尝试引用Visual Studio 2013中的静态库项目时发生链接器错误

Linker error when trying to reference static library project in Visual Studio 2013

本文关键字:项目 链接 错误 静态 Visual 引用 Studio 2013      更新时间:2023-10-16

我的Visual Studio解决方案中有两个项目:A(static library.lib项目)和B(使用A的项目)。我通过以下步骤引用了B中的A:

right click B > properties > common properties > references > add new reference > select A from projects tab

我已经使用properties > Configuration Properties > C/C++ > General 中的additional include directories选项设置了.h文件的路径

项目A在单独构建时成功构建。但在构建项目B时,它显示unresolved external symbol错误如下:

Error   46  error LNK2001: unresolved external symbol __imp____glewActiveTexture    c:Usersstudentdocumentsvisual studio 2013ProjectsMCAProjectNarovatarNarovatarOGLDEV_Imported.lib(ogldev_texture.obj)   Narovatar
Error   21  error LNK2001: unresolved external symbol __imp____glewAttachShader c:Usersstudentdocumentsvisual studio 2013ProjectsMCAProjectNarovatarNarovatarOGLDEV_Imported.lib(technique.obj)    Narovatar
Error   12  error LNK2001: unresolved external symbol __imp____glewBindBuffer   c:Usersstudentdocumentsvisual studio 2013ProjectsMCAProjectNarovatarNarovatarogl_mesh.obj  Narovatar
Error   13  error LNK2001: unresolved external symbol __imp____glewBufferData   c:Usersstudentdocumentsvisual studio 2013ProjectsMCAProjectNarovatarNarovatarogl_mesh.obj  Narovatar

我还能剩下什么?有什么想法吗?

右键单击properties -> linker -> general ->additional library directories-> browse for your lib file directory

右键单击"properties -> linker -> general ->input-> write your lib file name"。

不要忘记让它们两者MT二者MD,如下所示:

properties -> C/C++ -> Code generation -> Runtime-library-> change them both to be the same

我自己找到了答案,当然是在所有回应者的帮助下。事实上,项目A(.lib项目)的所有头文件和实现都在我在项目B中引用的同一个文件夹中。因此,当所有实现都可用时,我不必将项目A的.dll输出链接到项目B中,只需引用它即可。

另一个问题是,我没有(在项目B中)链接构建项目A所需的库。现在,它已经启动并运行。。。