Nickal
Nickal

Reputation: 737

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

I have two projects in my Visual Studio solution: A (static library .lib project) and B (project that uses A). I have referenced A in B by following the steps:

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

I have set the path for .h files using additional include directories option in properties > Configuration Properties > C/C++ > General

Project A builds successfully when built separately. But on building project B, it show unresolved external symbol errors like follows:

Error   46  error LNK2001: unresolved external symbol __imp____glewActiveTexture    c:\Users\student\documents\visual studio 2013\Projects\MCAProject\Narovatar\Narovatar\OGLDEV_Imported.lib(ogldev_texture.obj)   Narovatar
Error   21  error LNK2001: unresolved external symbol __imp____glewAttachShader c:\Users\student\documents\visual studio 2013\Projects\MCAProject\Narovatar\Narovatar\OGLDEV_Imported.lib(technique.obj)    Narovatar
Error   12  error LNK2001: unresolved external symbol __imp____glewBindBuffer   c:\Users\student\documents\visual studio 2013\Projects\MCAProject\Narovatar\Narovatar\ogl_mesh.obj  Narovatar
Error   13  error LNK2001: unresolved external symbol __imp____glewBufferData   c:\Users\student\documents\visual studio 2013\Projects\MCAProject\Narovatar\Narovatar\ogl_mesh.obj  Narovatar

What could I have left? Any thoughts?

Upvotes: 3

Views: 6250

Answers (2)

Nickal
Nickal

Reputation: 737

I have found my answer myself, of course with the help of help from all those who responded. Actually, the project A (.lib project) had all the header files and implementations in the same folder which I was referencing in the project B. So, when all the implementations were already available, I didn't have to link my the .dll output of project A in project B, but just had to refer it.

Another problem was that I had not linked (in project B) the libraries that were required for building project A. Now, its up and running...

Upvotes: 1

Humam Helfawi
Humam Helfawi

Reputation: 20314

Right click properties -> linker -> general ->additional library directories-> browse for your lib file directory.

Right click properties -> linker -> general ->input-> write your lib file name.

Do not forget to make them both MT or both MD like following:

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

Upvotes: 6

Related Questions