简体   繁体   English

如何使用Mingw或Cygwin编译和构建一个非常简单的Gnu linux应用程序到Windows?

[英]How to compile and build a very simple Gnu linux application to Windows using Mingw or Cygwin?

I would like to port an existing Linux application from its plain C/C++ source code to Windows XP/Vista/7 exactly same functionality to have, without losing few modules here and there etc. Basic codes are fine to build, but problem is the application I will be porting have other Linux dependencies. 我想将现有的Linux应用程序从其简单的C / C ++源代码移植到Windows XP / Vista / 7完全相同的功能,而不会丢失几个模块。基本代码可以构建,但问题是应用程序我将移植其他Linux依赖项。

Question: How can I port a C/C++ code which has other libraries dependencies, to Windows system? 问题:如何将具有其他库依赖性的C / C ++代码移植到Windows系统? Using MinGW. 使用MinGW。 Is there any IDE where I can do that? 有没有我可以做到的IDE? Or first of all I need to find out dependent libraries. 或者首先,我需要找出依赖库。 And then finally build the main application? 然后最终构建主应用程序?

Would it be possible to advise, a hello world for such application or reference to any resource which really works. 是否有可能为这样的应用建议一个问候世界或参考任何真正有用的资源。 Because I tried myself and i get fail building the other dependencies it has using MinGW. 因为我尝试了自己,并且在使用MinGW构建其他依赖项时失败了。 Follow up: 跟进:

  1. installing Cygwin 安装Cygwin

    1. http://cygwin.com/setup.exe http://cygwin.com/setup.exe
    2. C:/cygwin C:/ cygwin的
    3. make sure checked all gcc/g++/svn/wget etc... 确保检查所有gcc / g ++ / svn / wget等...
  2. install apt-cyg (good if it was default) 安装apt-cyg(如果是默认的话很好)

     wget rawgit.com/transcode-open/apt-cyg/master/apt-cyg install apt-cyg /bin 
  3. figured out that, this are related libraries for your apps 想通了,这是你的应用程序的相关库

     apt-cyg install libxml2 iconv bison flex pkg-config 
  4. install Linux apps to Windows apps 将Linux应用程序安装到Windows应用程序

     wget site/download/staffs tar xvfz staffs.tar.gz # your time saver apps ./configure make make install 

MinGW is, by nature, minimalist; MinGW本质上是极简主义的; it tries hard not to bring any baggage with it. 它努力不带任何包袱。 It sounds like you actually want baggage, in which case rather than using MinGW you should be using Cygwin , which emulates/implements many UNIX system calls and libraries on Windows. 听起来你真的想要行李,在这种情况下你应该使用Cygwin ,而不是使用MinGW,它在Windows上模拟/实现许多UNIX系统调用和库。 The whole GNU toolchain is there, and many times you can just run ./configure and make and everything works fine. 整个GNU工具链都在那里,很多时候你可以运行./configuremake ,一切正常。

Running on an emulation layer (a good suggestion) will get you going quickly, but it will be sub-optimal. 在仿真层上运行(一个好的建议)会让你快速前进,但它将是次优的。

Depending on your performance requirements, you may have to retool the app to replace the Linux-dependent code with either portable alternatives such as Boost or other portable library code, or Windows-specific replacement code of your own. 根据您的性能要求,您可能必须重新安装应用程序,以使用便携式替代方案(如Boost或其他可移植库代码)或您自己的Windows特定替换代码替换依赖于Linux的代码。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM