samnaction
samnaction

Reputation: 1254

Visual Studio 2012 additional library include from project property

I am trying following link to call dll function from a exe project in C++. In step 7 when I include the dll's lib file in the exe project through

TestExeProject->Properties->Linker->AdditionalLibraryDirectories, I am unable to compile the exe project. I am getting the following link error,

Error 1 error LNK2019: unresolved external symbol "__declspec(dllimport) public: __thiscall CTest::CTest(void)" (__imp_??0CTest@@QAE@XZ) referenced in function "protected: virtual int __thiscall CTestExeDlg::OnInitDialog(void)" (?OnInitDialog@CTestExeDlg@@MAEHXZ)

Error 2 error LNK2019: unresolved external symbol "__declspec(dllimport) int __cdecl fnTest(void)" (__imp_?fnTest@@YAHXZ) referenced in function "protected: virtual int __thiscall CTestExeDlg::OnInitDialog(void)" (?OnInitDialog@CTestExeDlg@@MAEHXZ)

The following issue I resolved by adding

#pragma comment(lib, "C:\\Users\\abc\\Documents\\Visual Studio 2010\\Projects\\Test\\Debug\\Test.lib")

But how to resolve this without adding this line but from the project properties?

Upvotes: 1

Views: 147

Answers (1)

CreativeMind
CreativeMind

Reputation: 917

You can link the lib (*.lib files) by following steps in Visual Studio:

  1. Configuration Properties->Linker->AdditionalLibraryDirectories (e.g "C:\Users\abc\Documents\Visual Studio 2010\Projects\Test\Debug" )

  2. Configuration Properties->Linker->Input->Additional Dependencies (e.g.: Test.lib; )

Upvotes: 1

Related Questions