error lnk1158 无法运行rc.exe

因为项目的需要安装了vs2012,可是安装成功后最简单的hello world都无法运行,一直报错error lnk1158 ,无法运行rc.exe。查找资料发现原因就是环境变量出现了问题。但是我修改了环境变量后还是一直没解决,然后就反反复复的重新安装了vs2012好几遍,还是没有解决问题。最后无意间想起在一个月前自己修改过C:\Users\administrator\appdata\local\microsft\msbuild\v4.0目录下的microsoft.cpp.win32.user.props文件,这个时候才恍然大悟。因为这个文件里面保存的就是环境变量等,所以在系统里面自己设置的那个环境变量无法加载进来,一直进行报错。找到问题后修改了这个配置文件,问题得到解决。


解决方法如下:

修改


C:\Users\Administrator.SDWM-20130627XZ\AppData\Local\Microsoft\MSBuild\v4.0


文件夹的Microsoft.Cpp.Win32.user.props文件






环境变量


1.   path


主要查看下列项


C:\Program Files\Microsoft ASP.NET\ASP.NET Web Pages\v1.0\;


C:\Program Files\Windows Kits\8.0\Windows Performance Toolkit\;


C:\Program Files\Microsoft SQL Server\110\Tools\Binn\;


C:\Users\Administrator.SDWM-20130627XZ\AppData\Local\Microsoft\MSBuild\v4.0;


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


给出一个给文件的配置

<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
  <ImportGroup Label="PropertySheets" />
  <PropertyGroup>
    <ExecutablePath>$(WindowsSDK_IncludePath);$(VCInstallDir)bin;$(WindowsSdkDir)bin\NETFX 4.0 Tools;$(WindowsSdkDir)bin;$(VSInstallDir)Common7\Tools\bin;$(VSInstallDir)Common7\tools;$(VSInstallDir)Common7\ide;$(ProgramFiles)\HTML Help Workshop;$(FrameworkSDKDir)\bin;$(MSBuildToolsPath32);$(VSInstallDir);$(SystemRoot)\SysWow64;$(FxCopDir);$(PATH);</ExecutablePath>
    <IncludePath>$(VCInstallDir)include;$(VCInstallDir)atlmfc\include;$(WindowsSdkDir)include;$(FrameworkSDKDir)\include;C:\Program Files\Microsoft SDKs\Windows\v7.0A\Include;</IncludePath>
    <ReferencePath>$(VCInstallDir)atlmfc\lib;$(VCInstallDir)lib;</ReferencePath>
    <LibraryPath>$(VCInstallDir)lib;$(VCInstallDir)atlmfc\lib;$(WindowsSdkDir)lib;$(FrameworkSDKDir)\lib;C:\Program Files\Microsoft SDKs\Windows\v7.0A\Lib;</LibraryPath>
    <SourcePath>$(WindowsSDK_LibraryPath_x86);$(VCInstallDir)atlmfc\src\mfc;$(VCInstallDir)atlmfc\src\mfcm;$(VCInstallDir)atlmfc\src\atl;$(VCInstallDir)crt\src;</SourcePath>
    <ExcludePath>$(VCInstallDir)include;$(VCInstallDir)atlmfc\include;$(WindowsSdkDir)include;$(FrameworkSDKDir)\include;$(MSBuildToolsPath32);$(VCInstallDir)atlmfc\lib;$(VCInstallDir)lib;</ExcludePath>
  </PropertyGroup>
</Project>

你可能感兴趣的:(Path,vs2012)