Reputation: 25592
I've been trying to get static libraries (.lib
files) to work in VS2010, and I have it working perfectly in the debug configuration. When I try to compile it under the release configuration, however, I get the error error C1083: Cannot open include file: 'Library.h': No such file or directory
.
Here's the current scenario:
.lib
file and a .h
file in a folder on my desktop called Static Library
.#include <Library.h>
)..lib
file as an additional dependency and set the directory for additional dependencies.My source code for the test program looks like this:
#include <iostream>
#include <Windows.h>
#include <Library.h>
int main()
{
std::cout << Library::GetValue(); // Returns 123.
Sleep(10000);
return 0;
}
What could I be doing incorrectly?
Upvotes: 0
Views: 759
Reputation: 1232
Not sure about VS2010... but the debug and release modes probably have different library settings...
You can inform the compiler to link thru code by specifying the following
#pragma comment(lib, "library.lib") // no ; is needed
That will make it link in both debug and release
Upvotes: 1