码迷,mamicode.com
首页 > Windows程序 > 详细

ubuntu下交叉编译windows c程序

时间:2017-01-05 08:00:13      阅读:540      评论:0      收藏:0      [点我收藏+]

标签:c99   install   输出   stat   static   runtime   交叉编译   .dll   链接库   

简介

采用mingw32可以在linux下直接编译c程序输出为windows下的exe程序或dll链接库。

个人编译的纯c程序(不含winapi),主要是c99程序,通常采用gcc/cc编译调试后,再用mingw输出win目标文件。

linux下目标程序及共享库与windows下的应用程序及链接库不同。

具体步骤

  1. 安装mingw

    sudo apt-get install mingw32 mingw32-binutils mingw32-runtime

    即使不输入mingw32-binutils和mingw32-runtime也会自动安装

  2. 编译

    i586-mingw32msvc-gcc hello.c -o hello.exe

  3. 个人习惯

    alias cl=’i586-mingw32msvc-gcc -std=c99’

    cl *.o -mdll -o test.dll

    cl hello.c -o hello.exe

mingw命令

  • C compiler: i586-mingw32msvc-gcc
  • C++ compiler: i586-mingw32msvc-g++
  • Linker for dynamic libs: i586-mingw32msvc-g++
  • Linker for static libs: i586-mingw32msvc-ar
  • Debugger: i586-mingw32msvc-gdb

http://hustlei.tk/2014/08/ubuntu-compile-c-for-win.html

 

ubuntu下交叉编译windows c程序

标签:c99   install   输出   stat   static   runtime   交叉编译   .dll   链接库   

原文地址:http://www.cnblogs.com/findumars/p/6251008.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!