http://wine-wiki.org/index.php/WineLib#Introduction
利用winelib编译一个可在linux下运行的程序
只是想既可以使用linux的api,又可以使用windows的api
#include <unistd.h> #include <windows.h> #include <stdio.h> #include <stdlib.h> int main(int argc, char* argv[]) { printf("long %d\n", sizeof(long)); system("lspci"); char bufr[256]; gethostname(bufr, sizeof(bufr)); strcat(bufr, " says, 'Howdy World!'"); MessageBox(NULL, bufr, "Junk", MB_OK); return(0); }
winegcc -m32 -o junk junk.c
得到
linux-b460:/home/winelib # ls
junk.c junk.exe junk.exe.so
运行
wine junk.exe.so
运行结果
linux-b460:/home//winelib # wine junk.exe.so
long 4
00:00.0 Host bridge: Intel Corporation Core Processor DRAM Controller (rev 18)
00:06.0 PCI bridge: Intel Corporation Core Processor Secondary PCI Express Root Port (rev 18)
00:1a.0 USB Controller: Intel Corporation 5 Series/3400 Series Chipset USB2 Enhanced Host Controller (rev 05)
00:1b.0 Audio device: Intel Corporation 5 Series/3400 Series Chipset High Definition Audio (rev 05)
00:1c.0 PCI bridge: Intel Corporation 5 Series/3400 Series Chipset PCI Express Root Port 1 (rev 05)
00:1c.4 PCI bridge: Intel Corporation 5 Series/3400 Series Chipset PCI Express Root Port 5 (rev 05)
00:1c.5 PCI bridge: Intel Corporation 5 Series/3400 Series Chipset PCI Express Root Port 6 (rev 05)
00:1c.6 PCI bridge: Intel Corporation 5 Series/3400 Series Chipset PCI Express Root Port 7 (rev 05)
00:1c.7 PCI bridge: Intel Corporation 5 Series/3400 Series Chipset PCI Express Root Port 8 (rev 05)
00:1d.0 USB Controller: Intel Corporation 5 Series/3400 Series Chipset USB2 Enhanced Host Controller (rev 05)
00:1e.0 PCI bridge: Intel Corporation 82801 PCI Bridge (rev a5)
00:1f.0 ISA bridge: Intel Corporation 3400 Series Chipset LPC Interface Controller (rev 05)
00:1f.2 IDE interface: Intel Corporation 5 Series/3400 Series Chipset 4 port SATA IDE Controller (rev 05)
00:1f.3 SMBus: Intel Corporation 5 Series/3400 Series Chipset SMBus Controller (rev 05)
00:1f.5 IDE interface: Intel Corporation 5 Series/3400 Series Chipset 2 port SATA IDE Controller (rev 05)
01:00.0 SCSI storage controller: LSI Logic / Symbios Logic SAS1068E PCI-Express Fusion-MPT SAS (rev 04)
05:00.0 Ethernet controller: Intel Corporation 82574L Gigabit Network Connection
06:00.0 Ethernet controller: Intel Corporation 82574L Gigabit Network Connection
07:05.0 VGA compatible controller: ASPEED Technology, Inc. ASPEED Graphics Family (rev 10)
Application tried to create a window, but no driver could be loaded.
Make sure that your X server is running and that $DISPLAY is set correctly.
err:systray:initialize_systray Could not create tray window
Application tried to create a window, but no driver could be loaded.
Make sure that your X server is running and that $DISPLAY is set correctly.
可以看到system是linux的api
messagebox是win的api,但是没有在x环境下所以报错
gcc版本是4.5,在4.7上编不过http://wiki.winehq.org/GccVersions
去掉-m32也编不过,也就是还只能生成32位的程序,对我用处不大,仅记录之