可以g ++ / minGW玩Windows SDK好吗?是Visual Studio唯一的选择吗? [英] Can g++ / minGW play nice with the Windows SDK? Is Visual Studio the only option?

查看:1320
本文介绍了可以g ++ / minGW玩Windows SDK好吗?是Visual Studio唯一的选择吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Windows XP上的g ++和minGW使用Windows SDK?



具体来说,g ++为什么无法编译:

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

int main(void){
printf(!!! Hello World !!!);
return EXIT_SUCCESS;
}



我已经尝试编译通过运行:

  g ++ -c -Wall Test.cpp -IC:/ Program\ Files / Microsoft\ Platform\ SDK / Include / 

我有一系列的编译错误以

开头

 code> winnt.h:666:2:#error必须定义目标体系结构。 

我安装了 Windows Server 2003 SP1平台SDK



/ h2>

我正在开发一个大型实时图像处理软件项目,直到现在已经使用g ++,minGW和gnu make文件(手写)。对于新功能,我需要与帧抓取器连接,该抓取器具有为Visual Studio 设计的SDK。 framegrabber SDK取决于Windows SDK的头文件。



我需要学习Visual Studio或有另一种方法吗?

解决方案

我使用MinGW每天编译Windows程序,没有问题。您的安装必须有问题 - 请尝试 Twilight Dragon Media 版本。



编辑:只需重新阅读您的帖子即可 - 您不需要像以前一样指定include目录,也不应该这样做。此外,您可能需要(或可能不需要)稍微神秘的 -mwindows 标志。我刚刚使用MinGW(TDM构建)g ++ 4.4.1编译程序,使用命令行:

  g ++ main.cpp 

完全没有问题。



更多信息:只是为了知道 -mwindows 标志的作用,GCC文档说:


此选项适用于Cygwin和
MinGW targets.It规定由
生成一个GUI
应用程序,指示链接器设置
PE标题子系统类型


就我个人而言,我从来没有必要,但是我的Windows应用程序都是命令行工具或服务器。 p>

Can g++ and minGW on Windows XP use the Windows SDK?

Specifically, why does g++ fail to compile:

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

int main(void) {
 printf("!!!Hello World!!!");
 return EXIT_SUCCESS;
}

I have tried compiling by by running:

g++ -c -Wall  Test.cpp -IC:/Program\ Files/Microsoft\ Platform\ SDK/Include/

I get a litany of compile errors beginning with

winnt.h:666:2: #error Must define a target architecture.

I have installed the Windows Server 2003 SP1 Platform SDK

Background

I am working on a large real-time image processing software project that up until now has used g++, minGW and gnu make files (written by hand). For a new feature, I need to interface with a frame grabber that has an SDK which was designed for Visual Studio. The framegrabber SDK depends on header files from the Windows SDK.

Do I need to learn Visual Studio or is there another way?

解决方案

I use MinGW to compile Windows programs every day, with zero problems. There must be something wrong with your installation - try the version at Twilight Dragon Media.

Edit: Just re-read your post - you do not need to specify the include directory as you are doing, and probably should not do so. Also, you may (or may not) need the slightly mysterious -mwindows flag. I just compiled your program using MinGW (TDM build) g++ 4.4.1, with the command line:

g++ main.cpp

with absolutely no problems.

More Info: Just so you know what the -mwindows flag does, the GCC docs say:

This option is available for Cygwin and MinGW targets.It specifes that a GUI application is to be generated by instructing the linker to set the PE header subsystem type appropriately.

Personally, I've never found it necessary, but then my Windows apps are all command line tools or servers.

这篇关于可以g ++ / minGW玩Windows SDK好吗?是Visual Studio唯一的选择吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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