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?
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
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.