LNK1104: cannot open file 'kernel32.lib'

风流意气都作罢 提交于 2019-12-11 02:28:28

问题


I Had VS2010 installed but found that intellisense wasn't working. I looked on the web and found that I wasn't the only one who had that issue. So, I installed VS2008 and everything was fine. Then I decided to clean up my computer and removed VS2010 and immediately started getting this error on my programs (new and old). Even a simple test program that has one cout command. I tried repairing VS2008 and that didn't work so I tried to uninstall and then reinstall and still I am getting the same problem.

I have looked online for this issue and though I have found a lot of other people are experiencing this issue it is not the same. They are having problems with other external references, not the ones that should automatically be included like kernel32 and lib32 etc.

I also tried the solution that worked for some people with their other references and I included the path (with and without quotes) to my kernel32 directory but still I get the same problem, or in some instances I will get

LNK1104: cannot open file 'C:\WINDOWS\system32.obj'

with and without quotes in the linker config.

Can anyone please help?


回答1:


I think the option you are looking for here is -MT instead of -MD. I ran into the same problem. You will notice that when you use this option, the size of the DLL is much larger (includes dependencies)




回答2:


I included the path (with and without quotes) to my kernel32 directory

It looks like you're pointing to C:\Windows\System32 which is where the DLL might be, but that's not where the .lib file will be.

In VS 2010 it's probably somewhere like:

C:\Program Files\Microsoft SDKs\Windows\v7.0A\Lib

I don't have ready access to VS2008 to say where kernel32.lib gets installed by default for that product.




回答3:


In case somebody comes up to this again, I found the solution which worked for me.

In my case UAC from Win 7 and / or antivirus sortware was / were denying the access to kernel32.lib. After starting VS 2008 as an Admin and deactivating Virus Scan for the project folders it worked for me.




回答4:


I had this problem and just resolved it. I had the SDK installed, however, the VCVARS32.bat couldn't find the SDK, so it defaulted to paths that didn't exist (where VS2008 is installed). I forced this to work by modifying the VCVARS32.bat ("C:\Program Files (x86)\Microsoft Visual Studio 9.0\Common7\Tools\vsvars32.bat", see line 13):

11: @call :GetWindowsSdkDir
12:
*13: @SET WindowsSdkDir=C:\Program Files\Microsoft SDKs\Windows\v6.0A\
14:
15: @if not "%WindowsSdkDir%" == "" (

I had to do it this way as I have VS2008, VS2010 and VS2012 installed, as most of us probably do who have to support multiple projects across multiple teams, so updating anything global, like the actual environmental path, could lead to mixing SDK versions.



来源:https://stackoverflow.com/questions/3926866/lnk1104-cannot-open-file-kernel32-lib

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!