我安装cross mingw编译器,将rpm转换成了deb并安装成功:
fakeroot alien -d *.rpm
sudo dpkg -i *.deb
编译测试程序:
#include <windows.h>
int WINAPI
WinMain (HINSTANCE hInstance, HINSTANCE hPrevInst, LPTSTR lpCmdLine, int nShowCmd)
{
MessageBoxW (NULL, L"Hello World!", L"hello", MB_OK | MB_ICONINFORMATION);
return 0;
}
编译,运行,也成功!
loaden@qpsoft:~$ i686-pc-mingw32-gcc main.cpp -o hello.exe -mwindows
loaden@qpsoft:~$ file ./hello.exe
./hello.exe: PE32 executable for MS Windows (GUI) Intel 80386 32-bit
于是我编译gcc,首先编译gmp和mpfr,都成功了。
方法:
一、编译gmp
../../src/gmp/configure --host=i686-pc-mingw32 --build=mingw32 --disable-shared
make
sudo make install
二、编译mpfr
../../src/mpfr/configure --host=i686-pc-mingw32 --build=mingw32 --with-gmp=/usr/local --disable-shared
make
sudo make install
然而,当我编译GCC时,却出现了找不到头文件windows.h的问题!
错误信息的一部分:
../../../../src/gcc/libiberty/pex-win32.c:24:21: 错误: windows.h:没有该文件或目录
../../../../src/gcc/libiberty/pex-win32.c:40:21: 错误: process.h:没有该文件或目录
../../../../src/gcc/libiberty/pex-win32.c:41:16: 错误: io.h:没有该文件或目录
../../../../src/gcc/libiberty/pex-win32.c: 在函数‘pex_win32_open_read’中:
../../../../src/gcc/libiberty/pex-win32.c:122: 警告: 隐式声明函数‘_open’
../../../../src/gcc/libiberty/pex-win32.c:122: 错误: ‘_O_RDONLY’未声明(在此函数内第一次使用)
../../../../src/gcc/libiberty/pex-win32.c:122: 错误: (即使在一个函数内多次出现,每个未声明的标识符在其
../../../../src/gcc/libiberty/pex-win32.c:122: 错误: 所在的函数内也只报告一次。)
../../../../src/gcc/libiberty/pex-win32.c:122: 错误: ‘_O_BINARY’未声明(在此函数内第一次使用)
../../../../src/gcc/libiberty/pex-win32.c:122: 错误: ‘_O_TEXT’未声明(在此函数内第一次使用)
../../../../src/gcc/libiberty/pex-win32.c: 在函数‘pex_win32_open_write’中:
../../../../src/gcc/libiberty/pex-win32.c:134: 错误: ‘_O_WRONLY’未声明(在此函数内第一次使用)
请问如何解决呢?
我尝试过:
1. 修改CFLAGS、CPPFLAGS
2. --with-sysroot
但都失败了。
注意:我不编译gcc,只在命令行下编译是可以找到windows.h的。
请帮忙给点提示、思路。
谢谢!