Linkage Error LNK1104 in Visual C++ 2010
Asked Answered
S

3

8

Today I fired up Visual Studio 2010 (Visual C++) and started working on a project. The solution contains two projects. One is a static library I am writing, the other is a test application containing unit tests for the library.

Without changing anything from yesterday, the executable no longer links:

LINK : fatal error LNK1104: cannot open file 'mylib.lib'

The static library compiles and links fine. I have not changed the project settings in around a week, and it was linking just fine yesterday.

If I go into the executable project's settings and add a library directory for $(SolutionDir)\debug, I instead get the following link error:

LINK : fatal error LNK1104: cannot open file 'kernel32.lib'

I am not sure what the problem is. I have tried cleaning, rebuilding, and even rebooting my machine. Google turned up some bugs in ancient Visual C++ versions (but I'm using 2010), as well as the possibility that the program is already running. However, it is not running, and a reboot confirms this.

What would cause the linker not to find core libraries such as kernel32.lib, or for that matter, the output directory for my solution?

This is old-fashioned C++, a cross-platform library, not that managed stuff Microsoft added.

Specht answered 4/9, 2010 at 21:42 Comment(0)
S
4

I had to check "Inherit from parent or project defaults" in the "Library Directories" dialog. Once I did that, the linker could find all the necessary libraries. I still had to include $(SolutionDir)\debug though.

Specht answered 5/9, 2010 at 21:33 Comment(0)
U
3

Include the microsoft SDK directory in project->properties->linker->general->additional library directories.

on my computer it is

D:\Program Files\Microsoft SDKs\Windows\v7.1\Lib

Unsettled answered 25/11, 2012 at 22:50 Comment(0)
I
1

I fixed this problem by disabling "Enable .NET Framework source stepping" (see: "Menu bar / Tools / Options / Debugging / General / Enable .NET Framework source stepping"). Apparently this is a bug in Visual Studio.

Isolationist answered 1/3, 2011 at 8:29 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.