致命错误 C1083:无法打开包含文件:'Windows.h':和 scons
今天是我正式接触 C++ 的第一天 :P
我已经下载了 Visual C++ 2005 Express Edition 和 Microsoft Platform SDK for Windows Server 2003 SP1,因为我想获得开源 Enso 项目。
因此,安装 scons 后,我转到控制台并尝试使用 scons 编译它,但出现此错误:
C:\oreyes\apps\enso\enso-read-only\src\platform\win32\Include\WinSdk.h(64) : fatal error C1083: Cannot open include file: 'Windows.h': No such file or directory
scons: *** [src\platform\win32\InputManager\AsyncEventProcessorRegistry.obj] Error 2
scons: building terminated because of errors.
检查这些链接后:
我已成功配置我的安装,如下所示:
甚至运行此脚本
并且我成功地在 IDE 中编译了以下文件。
// Test.cpp : Defines the entry point for the console application.
//
#include "stdafx.h"
#include <Windows.h>
int _tmain(int argc, _TCHAR* argv[])
{
return 0;
}
但我仍然在控制台中遇到该异常。 有人有scons经验吗?
编辑
实际上(我忘了告诉你这一点)我通过链接“Visual Studio 2005 命令提示符”启动了命令提示符。
我假设这将包括环境变量中的路径。 打印完它们后,我发现它没有:
echo %INCLUDE%
echo %LIB%
echo %PATH%
而且它们不存在,所以我创建了这个 .bat 文件:
set PATH=%PATH%;"C:\Program Files\Microsoft Platform SDK\Bin"
set INCLUDE=%INCLUDE%;"C:\ Program Files\Microsoft Platform SDK\Include"
set LIB=%LIB%;"C:\ Program Files\Microsoft Platform SDK\Lib"
尽管如此,scons 似乎不接受变量... :(
Today is officially my first day with C++ :P
I've downloaded Visual C++ 2005 Express Edition and Microsoft Platform SDK for Windows Server 2003 SP1, because I want to get my hands on the open source Enso Project.
So, after installing scons I went to the console and tried to compile it using scons, but I got this error:
C:\oreyes\apps\enso\enso-read-only\src\platform\win32\Include\WinSdk.h(64) : fatal error C1083: Cannot open include file: 'Windows.h': No such file or directory
scons: *** [src\platform\win32\InputManager\AsyncEventProcessorRegistry.obj] Error 2
scons: building terminated because of errors.
After checking these links:
I've managed to configure my installation like this:
And even run this script
And I managed to compile the file below in the IDE.
// Test.cpp : Defines the entry point for the console application.
//
#include "stdafx.h"
#include <Windows.h>
int _tmain(int argc, _TCHAR* argv[])
{
return 0;
}
But I still get that exception in the console. Does anyone have scons experience?
EDIT
Actually (and I forgot to tell you this) I started the command prompt with the link "Visual Studio 2005 Command Prompt".
I assume this will include the paths in environment variables. Well after printing them I find that it didn't:
echo %INCLUDE%
echo %LIB%
echo %PATH%
And they were not present, so I created this .bat file:
set PATH=%PATH%;"C:\Program Files\Microsoft Platform SDK\Bin"
set INCLUDE=%INCLUDE%;"C:\ Program Files\Microsoft Platform SDK\Include"
set LIB=%LIB%;"C:\ Program Files\Microsoft Platform SDK\Lib"
Still, scons seeems not to take the vars... :(
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(6)
这对我来说很有效,同时使用命令行提示符使用 Visual C++ 2005 Express 编译 wxwidgets:(
编译时使用 /useenv 选项。)
(更改为正确的选项。)
然后我在编译时使用这一行。 我相信只需将
/useenv
添加到您的行中,一切都会正常工作:This works for me while compiling wxwidgets with Visual C++ 2005 Express using the command line prompt:
(Use /useenv option when compiling.)
(Change to the right one.)
Then I use this line when compiling. I believe just add
/useenv
to your lines and everything should work fine:使用上述建议不适用于 scons:scons 不导入用户环境(PATH 和其他变量)。 根本问题是 scons 不处理最新版本的 SDK/VS 。
我偶尔是 scons 的贡献者,并且正在开发 ATM 的这个功能。 希望它很快就会被包含在 scons 中,但是该功能比我最初预期的更难可靠地实现,部分原因是每个 sdk/编译器组合都是不同的(有时甚至 MS 也没有得到正确的结果,他们的一些 .bat 文件)坏了),所以我不能给你一个约会。 我希望它能包含在 1.2 中(大约一个月后发布)。
Using the above recommendations will not work with scons: scons does not import the user environment (PATH and other variables). The fundamental problem is that scons does not handle recent versions of SDKs/VS .
I am an occasional contributor to scons, and am working on this feature ATM. Hopefully, it will be included soon in scons, but the feature is much harder to implement reliably than I first expected, partly because every sdk/compiler combination is different (and sometimes even MS does not get it right, some of their .bat files are broken), so I can't give you a date. I hope it will be included in 1.2 (to be released in approximatively one month).
您需要设置包含文件路径(以及可能的其他内容)。 在命令行中,这通常是使用 Visual Studio 安装的名为
vsvars32.bat
(或vcvars32.bat
以与 VC6 兼容)的批处理文件完成的。我不熟悉 scons,所以我不知道为该工具配置这些设置的最佳方法,但对于标准 makefile,makefile 中通常有一行使用包含目录路径设置宏变量,该宏是用作调用编译器的命令中命令行参数的一部分。
另一种可能性可能是让 scons 进程调用 vsvars32.bat 或从已使用批处理文件配置的命令行运行 scons 脚本。
简而言之,您需要以某种方式将 vsvars32.bat 配置的内容放入 scons 配置中。
You need to set the include file path (and possibly other things). At the command line this is typically done using a batch file that Visual Studio installs called
vsvars32.bat
(orvcvars32.bat
for compatibility with VC6).I'm not familiar with scons so I don't know the best way to get these settings configured for that tool, but for standard makefiles there's usually a line in the makefile which sets a macro variable with the include directory path and that macro is used as part of a command line parameter in the command that invokes the compiler.
Another possibility might be to have the scons process invoke vsvars32.bat or run the scons script from a command line that has been configured with the batch file.
In short you need to get the things that vsvars32.bat configures into the scons configuration somehow.
将有一个与此类似的批处理文件(对于 MSVC 2005),用于设置环境变量:
第 1 步:在 Express 安装文件夹中找到类似的文件
第 2 步 :在桌面上创建一个包含这些目标详细信息和经过适当修改的路径的快捷方式:
第 3 步:通过此快捷方式打开 DOS 提示符
命令行构建现在应该可以在其中运行这个控制台窗口。
There will be a batch file similar to this one (for MSVC 2005) that sets up the environment variables:
Step 1: Find a similar file in the Express installation folders
Step 2: Create a shortcut on the desktop with these target details and a suitably modified path:
Step 3: Open the DOS prompt via this shortcut
The command line build should now work from within this console window.
您向我们展示了如何在 Visual Studio 中配置 Visual Studio 进行编译,但没有向我们展示您尝试过的命令行环境。 抱歉,我没有尝试过 Express 版本,所以我不知道他们是否像 Pro 及以上版本那样创建额外的“开始”菜单快捷方式。 如果您打开合适的命令提示符并已设置其环境变量,则可以在命令行上进行编译。 否则,每次打开命令提示符时,您都必须自己设置变量或执行批处理脚本来设置它们。
You show us how you configured Visual Studio for compilations within Visual Studio but you didn't show us what command line environment you tried. Sorry I haven't tried Express versions so I don't know if they create additional Start menu shortcuts like Pro and above do. If you open a suitable command prompt with its environment variables already set then you can compile on the command line. Otherwise you have to set variables yourself or execute a batch script to set them, each time you open a command prompt.
如果 scons 自动执行此操作,那就太好了。 目前,我使用这个(从 SDK 命令提示符运行,不确定在 vsvars32.bat 之后运行是否有区别):
It'll be nice when scons does this automatically. For now, I use this (run from an SDK command prompt, not sure if there is a difference if run after vsvars32.bat):