Maxpm
Maxpm

Reputation: 25592

C++ Library Does Not Link in Release Configuration (VS2010)

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:

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

Answers (1)

oldSkool
oldSkool

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

Related Questions