利用winelib编译一个可在linux下运行的程序
2013-08-09 13:08
453 查看
http://wine-wiki.org/index.php/WineLib#Introduction
利用winelib编译一个可在linux下运行的程序
只是想既可以使用linux的api,又可以使用windows的api
在64位机器上编译
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位的程序,对我用处不大,仅记录之
利用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); }
在64位机器上编译
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位的程序,对我用处不大,仅记录之
相关文章推荐
- 在ubunt14.04(linux)下利用cmake编译运行opencv程序
- 在linux环境下编译运行OpenCV程序的两种方法
- Linux下计算程序运行时间的一个简单方法
- Linux环境下部署完JDK后运行一个简单的Java程序
- 编译运行symbian程序(如何打开一个symbian工程)
- Android 运行 C/C++程序 (使用 arm-linux-gcc 交叉编译环境)
- Linux下如何编译并运行C程序
- 一个 Linux Windows下都可运行的 Socket 程序
- 在linux环境下编译运行OpenCV程序的两种方法
- 【Linux】使用vim编写一个程序,gcc查看预处理、编译、汇编、链接过程
- linux下如何编译运行c程序
- C#利用Mutex实现只运行一个程序实例
- Linux下C程序的编辑,编译和运行以及调试
- 如何在Windows下使用Linux系统来编译和运行程序?
- 一个C程序的编译过程(Linux环境下Gcc)
- 利用文件锁保证一个程序最多只有一份拷贝在运行
- linux下利用nohup后台运行jar文件包程序
- 学了C语言,如何利用CURL写一个下载程序?—用nmake编译CURL并安装
- Linux下编译并运行C程序
- 在ubuntu下创建、编译并运行一个C++程序的过程