致命错误 C1083:无法打开包含文件:'Windows.h':和 scons

发布于 2024-07-07 02:25:40 字数 2010 浏览 6 评论 0原文

今天是我正式接触 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.

检查这些链接后:

VS ans PSDK

包含 tiffi.h

Wndows.h

我已成功配置我的安装,如下所示:

alt text

甚至运行此脚本

alt text

并且我成功地在 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:

VS ans PSDK

Include tiffi.h

Wndows.h

I've managed to configure my installation like this:

alt text

And even run this script

alt text

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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(6

若言繁花未落 2024-07-14 02:25:41

这对我来说很有效,同时使用命令行提示符使用 Visual C++ 2005 Express 编译 wxwidgets:(

REM Fix Error error C1083 'windows.h'

编译时使用 /useenv 选项。)

set PDSKWIN=C:\Program Files\Microsoft Platform SDK for Windows Server 2003 R2

(更改为正确的选项。)

set INCLUDE=%PDSKWIN%\Include;%INCLUDE%

set LIB=%PDSKWIN%\Lib;%LIB%

然后我在编译时使用这一行。 我相信只需将 /useenv 添加到您的行中,一切都会正常工作:

vcbuild /useenv /nohtmllog /nologo name.proj (or any file to compile)

This works for me while compiling wxwidgets with Visual C++ 2005 Express using the command line prompt:

REM Fix Error error C1083 'windows.h'

(Use /useenv option when compiling.)

set PDSKWIN=C:\Program Files\Microsoft Platform SDK for Windows Server 2003 R2

(Change to the right one.)

set INCLUDE=%PDSKWIN%\Include;%INCLUDE%

set LIB=%PDSKWIN%\Lib;%LIB%

Then I use this line when compiling. I believe just add /useenv to your lines and everything should work fine:

vcbuild /useenv /nohtmllog /nologo name.proj (or any file to compile)
白昼 2024-07-14 02:25:40

使用上述建议不适用于 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).

阳光①夏 2024-07-14 02:25:40

您需要设置包含文件路径(以及可能的其他内容)。 在命令行中,这通常是使用 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 (or vcvars32.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.

猫性小仙女 2024-07-14 02:25:40

将有一个与此类似的批处理文件(对于 MSVC 2005),用于设置环境变量:

c:\Program Files\Microsoft Visual Studio 8\Common7\Tools\vsvars32.bat

第 1 步:在 Express 安装文件夹中找到类似的文件

第 2 步 :在桌面上创建一个包含这些目标详细信息和经过适当修改的路径的快捷方式:

cmd.exe /K "c:\Program Files\Microsoft Visual Studio 8\Common7\Tools\vsvars32.bat"

第 3 步:通过此快捷方式打开 DOS 提示符

命令行构建现在应该可以在其中运行这个控制台窗口。

There will be a batch file similar to this one (for MSVC 2005) that sets up the environment variables:

c:\Program Files\Microsoft Visual Studio 8\Common7\Tools\vsvars32.bat

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:

cmd.exe /K "c:\Program Files\Microsoft Visual Studio 8\Common7\Tools\vsvars32.bat"

Step 3: Open the DOS prompt via this shortcut

The command line build should now work from within this console window.

丑丑阿 2024-07-14 02:25:40

您向我们展示了如何在 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.

裂开嘴轻声笑有多痛 2024-07-14 02:25:40

如果 scons 自动执行此操作,那就太好了。 目前,我使用这个(从 SDK 命令提示符运行,不确定在 vsvars32.bat 之后运行是否有区别):

import os
env = Environment(ENV={'PATH': os.environ['PATH']})

env['ENV']['TMP'] = os.environ['TMP']
env.AppendUnique(CPPPATH=os.environ['INCLUDE'].split(';'))
env.AppendUnique(LIBPATH=os.environ['LIB'].split(';'))

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):

import os
env = Environment(ENV={'PATH': os.environ['PATH']})

env['ENV']['TMP'] = os.environ['TMP']
env.AppendUnique(CPPPATH=os.environ['INCLUDE'].split(';'))
env.AppendUnique(LIBPATH=os.environ['LIB'].split(';'))
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文