简体   繁体   English

VS2015未链接user32.lib

[英]VS2015 not linking user32.lib

I just inherited maintenance on a 10-year-old project, which includes moving it from VS2005 to VS2015. 我只是继承了一个已有10年历史的项目的维护工作,其中包括将其从VS2005迁移到VS2015。 I'm most of the way there, but when I link I get this error: 我在这里很方便,但是当我链接时出现此错误:

error LNK2019: unresolved external symbol __imp__MessageBoxA@16 错误LNK2019:无法解析的外部符号__imp__MessageBoxA @ 16

A quick search found that that this requires user32.lib. 快速搜索发现这需要user32.lib。 When I go to properties->linker->Additional Dependencies, I see that library liste under Inherited Values, but it still doesn't link. 当我转到properties-> linker-> Additional Dependencies时,我在继承的值下看到该库liste,但是它仍然没有链接。 When I explicitly add the hardcoded path and filename (C:\\Program Files (x86)\\Windows Kits\\8.1\\Lib\\winv6.3\\um\\x86\\user32.lib) as another dependency, then it does successfully link... which is okay, I guess, but if nothing else it's ugly that I'm relying on that particular install location (you know software developers are going to decide to stick things in odd places)... Anybody have any guesses as to why visual studio isn't finding the library in the first place, and how to fix it the right way? 当我明确添加硬编码的路径和文件名(C:\\ Program Files(x86)\\ Windows Kits \\ 8.1 \\ Lib \\ winv6.3 \\ um \\ x86 \\ user32.lib)作为另一个依赖项时,它确实可以成功链接...我猜这没关系,但如果没有其他问题,我要依靠那个特定的安装位置是很丑陋的(您知道软件开发人员将决定将东西粘贴在奇怪的地方)...任何人都对为什么视觉效果有任何猜测studio并不是首先找到该库,而如何正确地修复它呢?

在项目级别获取对lib文件的依赖性,然后将路径添加到属性页

The Windows Kits\\8.1 tells you that you have the Windows 8.1 SDK installed. Windows Kits\\8.1告诉您已安装Windows 8.1 SDK。 There's a Windows 10 SDK by now, but that probably doesn't really matter to you - user32.lib has been around since forever. 到目前为止,已经有了Windows 10 SDK,但这对您可能并不重要-user32.lib一直存在至今。

The problem here seems to be that while you have the 8.1 SDK installed, Visual Studio isn't aware of it. 这里的问题似乎是,当您安装了8.1 SDK时,Visual Studio并不知道它。 IIRC, it's in the VS2015 installer, so you can rerun that and re-select the SDK there. IIRC,它在VS2015安装程序中,因此您可以重新运行它并在此处重新选择SDK。 (Or pick another SDK - you're likely going to be restricting the SDK to Win7 anyway) (或者选择另一个SDK-无论如何,您可能都将SDK限制为Win7)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM