我可以使用 Cygwin 或 MinGW,但我需要最终得到 64 位代码,而不是 32 位。这是因为我将从 64 位托管 C# 调用 DLL。我似乎找不到关于设置这些工具来创建 64 位二进制文件的良好参考。另外,如果 GCC 是版本 4,而不是我的 Cygwin 安装附带的版本 3,那就太好了。
另一种选择是某种形式的进程间通信。我会研究这个,但我上面列出的是我真正想要的。
The 64位MinGW http://sourceforge.net/projects/mingw-w64基于(刚刚发布的)gcc-4.4.0,可能是您最好的选择。
(由于 sourceforge.net 上的 mingw-w64 项目正在迁移到 mingw-w64.org,因此最好使用mingw-w64.org http://mingw-w64.org)
详细说明:
1. 下载
2. 将其解压到 cygwin 下的某个位置。就我而言,顶级 cygwin 目录是C:\cygwin
,我将包解压到mingw
目录,最终得到以下内容C:\cygwin\mingw
(可见/mingw
在 Cygwin 下:
$ ls -l /mingw
total 1
drwxr-xr-x+ 2 user None 0 May 10 08:32 bin
drwxr-xr-x+ 2 user None 0 May 10 05:45 include
drwxr-xr-x+ 2 user None 0 May 10 08:30 info
drwxr-xr-x+ 3 user None 0 May 10 08:30 lib
drwxr-xr-x+ 3 user None 0 May 10 05:45 libexec
drwxr-xr-x+ 4 user None 0 May 10 05:45 man
lrwxrwxrwx 1 user None 17 May 17 17:20 mingw -> x86_64-pc-mingw32
drwxr-xr-x+ 3 user None 0 May 10 04:16 share
drwxr-xr-x+ 5 user None 0 May 10 04:18 x86_64-pc-mingw32
3. 现在编译一些 C++ 代码。我用了:
// t.cc
#include <vector>
#include <string>
using namespace std;
int main()
{
vector<string> vs;
vs.push_back("abc");
}
并像这样编译它:
$ /mingw/bin/x86_64-pc-mingw32-g++ t.cc
4. 最后,通过运行验证结果是 Windows/x 64 可执行文件dumpbin /headers a.exe
:
Microsoft (R) COFF/PE Dumper Version 7.00.9466
Copyright (C) Microsoft Corporation. All rights reserved.
Dump of file a.exe
PE signature found
File Type: EXECUTABLE IMAGE
FILE HEADER VALUES
8664 machine (AMD64)
10 number of sections
4A10AF9F time date stamp Sun May 17 17:45:19 2009
ABA00 file pointer to symbol table
EC4 number of symbols
F0 size of optional header
27 characteristics
Relocations stripped
Executable
Line numbers stripped
Application can handle large (>2GB) addresses
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)