2012-03-01 84 views
3

错误消息compling一个Win32项目:缺少sal.h同时通过MinGW的

fatal error: sal.h: No such file or directory cstudy line 11, external location: C:\Program Files\Microsoft SDKs\Windows\v7.0A\Include\specstrings.h C/C++ Problem.

但是,当I /包括添加VC这个项目,我收到一吨的错误消息。看来VC/include/sal.h不是GCC的标准头文件。

的源代码是非常简单的:

#include "windows.h" 
int WINAPI WinMain(HINSTANCE hInstance,HINSTANCE hPrevInstance,LPSTR lpCmdLine,int nCmdShow) 
{ 

    return 0; 
} 

环境:

  • 的Windows SDK 7.0A
  • VC 2010
  • MINGW
  • CDT/ECLIPSE。

感谢。

+0

你们是不是要编译Windows代码的MinGW的?你可能应该使用visual studio编译器来这样做。 – 2012-03-01 06:13:23

+2

您是否安装了MinGW WIN32 API包?另外,你应该使用'#include ',因为它是一个系统头文件。 – 2012-03-01 08:09:46

回答

1

没有,sal.h头是GCC/MinGW的的一部分,但是你可以添加你VC/include/为包括目录偏食。

替代:(!)移动所有 requried头到你的MinGW或项目include目录。 MinGw的一个是:<mingw path>/include)。

Anyway. sal.h, if you install the Windows SDK then it isn't going to be in the SDK directory, but you should find that if you select to install the compiler and tools it will get installed along with that. This is because sal.h is needed in the CRT headers as well as the Windows headers. So you NEED to install the VS compilers and tools along with the SDK. You will then find that the compiler will be installed by default under %ProgramFiles%\Microsoft Visual Studio 2010\VC and sal.h will be in include under that path. On 64 bit systems it will be under %ProgramFiles(x86)% by default.

来源:http://social.msdn.microsoft.com/Forums/eu/windowssdk/thread/0e166050-99f1-436b-bd94-b39e2910f43d

教廷:(!)

0

我刚碰到这个问题。我似乎无法通过mingw的MS Windows版本获取sal.h头文件,但是在我的Fedora Core 18机器上“yum whatprovides \ */sal.h”引发了mingw-headers包。我下载了源码包(例如yumdownloader --source mingw-headers),打开文件滚轮中的.tar.gz文件,抓住sal.h文件,并将它放在我的MS Windows上的/ c/MinGW/include中机。

相同的软件包有dsound.h,这是下一个缺失的头文件。

我从来没有尝试过使用MinGW的Fedora Core中交叉编译微软Windows应用程序,但也许是时候... :-)