Code::Blocks C/C++ windows.h 缺少致命错误 [英] Code::Blocks C/C++ windows.h missing fatal error

查看:102
本文介绍了Code::Blocks C/C++ windows.h 缺少致命错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

问题:

我尝试用 Microsoft Visual C++ 2010 Compiler 编译一个简单的 C++ 源文件,我遇到了一个错误.我已经安装了 Microsoft Visual C++ 2010 和 MinGW 并找到了 windows.h 文件,我还在 Code::Blocks 中配置了额外文件的目录.

I tried to compile a simple c++ source file with Microsoft Visual C++ 2010 Compiler, and I encountered an error. I've installed Microsoft Visual C++ 2010 and MinGW and located the windows.h file, I've also configured the directory of extra files in Code::Blocks.

代码:

#include <stdio.h>
#include <stdlib.h>
#include <windows.h>

int main(){
    printf("Hello World!");

    getchar();
}

错误:

F:\test2.cpp(3) : fatal error C1083: Cannot open include file: 'windows.h': No such file or directory

推荐答案

为了在使用 Code::Blocks IDE 时利用多个编译器,您需要确保正确配置每个编译器的设置.这些可以通过 Settings->Compiler 菜单选项访问.

In order to utilize multiple compilers when using the Code::Blocks IDE, you need to ensure that the settings for each compiler are properly configured. These may be accessed via the Settings->Compiler menu option.

选择要配置的编译器后,您需要选择Search Directories 选项卡并确保CompilerLinkerResource Compiler 选项卡包含相应的文件夹.每个选项卡可能需要在搜索框中输入多个文件夹.

After selecting the compiler that one wishes to configure, you need to select the Search Directories tab and ensure that the Compiler, Linker and Resource Compiler tabs contain appropriate folders. Each tab will possibly need several folders entered into the search box.

使用 Visual Studio C++ 2010 编译器的示例,每个选项卡都将包含对两者的引用

Using the example of the Visual Studio C++ 2010 compiler, each tab will contain a reference to both

  1. 适当的文件夹,在 VS 的安装位置找到
  2. 适当的文件夹,在安装位置找到平台 SDK
  1. the appropriate folder, as found in the install location of VS
  2. the appropriate folder, as found in the install location of the Platform SDK

就我而言,文件夹位置是:

In my case, the folder locations are:

编译器

  • C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\include
  • C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\include

链接器

  • C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\lib
  • C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\lib

资源编译器

  • C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\include
  • C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\include

这篇关于Code::Blocks C/C++ windows.h 缺少致命错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆