I am trying to access the .lib file using visual studio 2012. below are the steps I followed
Created a class library, and included header(.hpp) and .lib file
Header file :-
extern "C" unsigned int GetKey();
Class library
public: static unsigned int GetKey1() { return GetKey(); }
Built the application and it is successful, lets call it as classlibrary
- Created a win 32 console application and added the above dll as reference, tried to access the method in dll, built got succeed, but when i tried to run it , it showing file not found exception in classlibrary.dll or its dependencies like below.
Source file
using namespace ManagedMathFuncsLib;
int main()
{
Class1 cs;
cout<<"default value of variable from dll : "<< cs.GetKey1()<<endl;
return 0;
}
Error
An unhandled exception of type 'System.IO.FileNotFoundException' occurred in Unknown Module.
Additional information: Could not load file or assembly 'XXXXXXX.dll' or one of its dependencies. The specified module could not be found.
If there is a handler for this exception, the program may be safely continued.
**Do i need the dll related to .lib file? Please help.**
If you want to create a static C/C++ library (.lib) without a DLL.
With such a static lib, you just need a header file and the lib to include it into another project.
There is no when you use a static lib.
PS: You should create a static libs for Debug and Release mode. Also you need to take care about the switches that control how the CRT is used inside the Lib. This Compiler switches should be identical in the lib and in the project were you use the lib.