VS2010编译工具出错的解决办法

一、问题现象
VC2010编译任何工程都出错。
错误信息:
1>------ Build started: Project: UserModule, Configuration: Debug Win32 ------
1>C:\Program Files\MSBuild\Microsoft.Cpp\v4.0\Platforms\Win32\Microsoft.Cpp.Win32.Targets(147,5): error MSB6006: "CL.exe" exited with code -1073741515.
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
二、解决办法1、原因
通过观察,发现工程属性中的可执行文件路径指向VC2008的路径。
2、一种临时解决办法
设置工程属性中的可执行文件路径。
C:\Program Files\Microsoft Visual Studio 10.0\VC\bin
12818368.png
 
设置之后,编译果然成功了。
但是,不可能每个工程都去修改一次工程属性吧?
3、最终解决办法
在Property Manager中修改VC++目录(注:这里的修改是全局生效的。与项目、属性中的设置不同。)
 
打开Property Manager的方法:
View->Property Manager (it is near the bottom) or View->Other Windows->Property Manager
修改为:(ExcludePath暂时未做修改)
C:\Program Files\Microsoft Visual Studio 10.0\VC\bin;C:\Program Files\Microsoft Visual Studio 10.0\VC\atlmfc\include;$(ExecutablePath)
C:\Program Files\Microsoft Visual Studio 10.0\VC\include;$(IncludePath)
C:\Program Files\Microsoft Visual Studio 10.0\VC\lib;C:\Program Files\Microsoft Visual Studio 10.0\VC\atlmfc\lib;$(ReferencePath)
C:\Program Files\Microsoft Visual Studio 10.0\VC\lib;C:\Program Files\Microsoft Visual Studio 10.0\VC\atlmfc\lib;$(LibraryPath)
C:\Program Files\Microsoft Visual Studio 10.0\VC\atlmfc\src\mfc;C:\Program Files\Microsoft Visual Studio 10.0\VC\atlmfc\src\atl;C:\Program Files\Microsoft Visual Studio 10.0\VC\atlmfc\src\mfcm;C:\Program Files\Microsoft Visual Studio 10.0\VC\crt\src;$(SourcePath)
17083185.png
 
 
注:
网上也有资料介绍下面这种清除用户数据的方法,但我的环境上这种操作不能解决问题。
 
打开VS2010命令行,执行 devenv /ResetUserData, 稍等一会,完成。
然后再启动VS2010,会提示第一次启动时的环境设置对话框,去掉“Migrate 老的设置”前面的对勾,然后启动VS2010。
14301734.png
 
三、参考资料
感谢这个帖子中提供解决方案的crescens2k。

http://social.msdn.microsoft.com/Forums/en-CA/vcgeneral/thread/ca399aec-1b5e-41a3-9cd5-76a74420f940

Right, if you notice the path to your compiler it is actually picking up the VC9 compiler on your system. This is why you are getting this problem. This is a known bug in the environment.

What you can try is

1) Open your Visual Studio Command Prompt (Can get to it through Start->All Programs->Microsoft Visual Studio 2010->Visual Studio Tools->Visual Studio Command Prompt)

2) Run DevEnv /ResetUserData wait for it to finish (it may take a while)

3) Open Visual Studio itself and it will give you the same window as when you first run Visual Studio. Make sure you deselect Migrate my eligable settings checkbox before you select your configuration and then select Start Visual Studio.

4) Open your project and try again.

If it still fails then it is likely that something was saved into the project itself. In this case go to Project Properties->Configuration Properties->VC++ Directories and replace set each of the Paths to the Following

Executable Directories to $(ExectablePath)

Include Directories to $(IncludePath)

Reference Directories to $(ReferencePath)

Library Directories to $(LibraryPath)

Source Directories to $(SourcePath)

Exclude Directories to $(ExcludePath)

Please note you need to keep the exact formatting, so when you locate Executable Directories, in the box on the right replace the entire contents with $(ExecutablePath) for example. If you do that you will put the project specific settings to the default too and (hopefully) will fix everything.

----------------------------------------

It was still inherited even after you reset your environment?

Hmm, ok.

Open up Property Manager, if you selected the VC configuration then it should be on the left automatically. If not, you can find it either under View-&gt;Property Manager (it is near the bottom) or View-&gt;Other Windows-&gt;Property Manager. You will need a VC project loaded. In Property Manager, under <Project Name>-&gt;Debug | Win32 look for Microsoft.Cpp.Win32.User.

Right click on this and select properties. Go to Common Properties-&gt;VC++ Directories and check these out. But since these should inherit from the others directly then the best you can do is override the paths yourself here. The only thing that I could think of to override these is if you have VSINSTALLDIR and VCINSTALLDIR set on a global scale.

Could you look at one final thing, if you go to Control Panel-&gt;System-&gt;Advanced system settings and click on the Environment Variables button. Under either of these can you find VCINSTALLDIR and VSINSTALLDIR set to anything?

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值