将C/ c++代码从Linux移植到Windows的最佳环境

时间:2021-12-30 15:07:17

I'd like to make a big project of mine buildable on Windows platforms. The project itself it's written in C/C++ following POSIX standards, with some library dependencies such as libxml2, libcurl and so on. I'm more a Linux developer rather than a Windows developer, so i have no idea of which compiler suite i should use to port the code. Which one offers more compatibility with gcc 4.4.3 i'm using right now?

我想在Windows平台上做一个大项目。项目本身是用C/ c++编写的,遵循POSIX标准,并带有一些库依赖项,如libxml2、libcurl等等。我更多的是一个Linux开发人员,而不是Windows开发人员,所以我不知道应该使用哪个编译器套件来移植代码。哪一个更适合我现在使用的gcc 4.4.3 ?

My project needs flex and bison, is there any "ready to use" environment to port such projects to windows platforms?

我的项目需要flex和bison,是否有“准备好使用”环境将这些项目移植到windows平台上?

Thanks.

谢谢。

4 个解决方案

#1


11  

If it were me, I would install the following:

如果是我,我会安装以下软件:

  • MinGW port of the GCC compiler from Twilight Dragon (this is only at 4.4.1 at present, but I'd guess it will meet your needs, and I've found it to be very reliable)

    来自《暮光之龙》的GCC编译器的MinGW端口(目前只有4.4.1,但我想它会满足您的需要,我发现它非常可靠)

  • The MSYS environment (bash etc. for Windows) from http://sourceforge.net/apps/mediawiki/cobcurses/index.php?title=Install-MSYS

    MSYS环境(Windows的bash等)来自http://sourceforge.net/apps/mediawiki/cobcurses/index.php?

  • Various tools like flex from http://gnuwin32.sourceforge.net/

    各种工具,比如来自http://gnuwin32.sourceforge.net/的flex

This is effectively the environment I do my own programming in, and it works very well. If you want an IDE, I'd recommend Code::Blocks, but both gvim and emacs are available for Windows too.

这是我自己编程的有效环境,而且运行得非常好。如果您想要一个IDE,我推荐代码::Blocks,但是gvim和emacs都可以用于Windows。

#2


4  

If you don't use any UNIX system calls so you can run on Windows freely. There are flex & bison for windows too: http://gnuwin32.sourceforge.net/packages.html . You can go ahead with MinGW: http://www.mingw.org/ .

如果不使用任何UNIX系统调用,则可以在Windows上*运行。windows也有flex和bison: http://gnuwin32.sourceforge.net/packages.html。你可以使用MinGW: http://www.mingw.org/。

If you have UNIX system calls, then you have to use cygwin: http://www.cygwin.com/ , http://en.wikipedia.org/wiki/Cygwin .

如果您有UNIX系统调用,那么您必须使用cygwin: http://www.cygwin.com/, http://en.wikipedia.org/wiki/Cygwin。

#3


1  

I very much doubt either cygwin nor mingw is up to 4.4.3 yet. I would bet on being able to upgrade the compiler in mingw to be easier.

我非常怀疑cygwin和mingw是否达到了4.4.3。我敢打赌,在mingw中升级编译器会更容易。

You'll need cygwin if you're actually using any Linux specific stuff. The libraries you listed off aren't an issue I don't think. POSIX could be, depending.

如果您实际使用任何特定于Linux的东西,您将需要cygwin。我不认为你列出的库是一个问题。POSIX可能不同。

#4


1  

A nice new alternative is Cygnal. The basic idea:

一个不错的新选择是Cygnal。它的基本思想是:

  • First, compile the code under Cygwin for Cygwin itself using its "native" toolchain (not MinGW).
  • 首先,使用“本机”工具链(不是MinGW)为Cygwin本身编译Cygwin下的代码。
  • Next, deploy the program with the Cygnal version of the Cygwin DLL.
  • 接下来,使用Cygwin DLL的Cygnal版本部署程序。

Cygnal is a fork of the primary Cygwin DLL which changes certain behaviors which are too Unix like.

Cygnal是Cygwin DLL的一个分支,它改变某些行为,这些行为太像Unix。

Cygwin's motto is "get that Linux feeling on Windows". Cygnal tones down that feeling; it brings back some of the Windows feeling to programs, so that those programs work for Windows users outside of the Cygwin environment using Windows conventions.

Cygwin的座右铭是“在Windows上感受Linux”。Cygnal缓和了这种感觉;它给程序带来了一些Windows的感觉,因此这些程序可以为Cygwin环境之外的Windows用户使用Windows约定。

Programs understand native paths, and such. None of the rich API functionality in Cygwin is removed, only a small portion of it is adjusted.

程序理解本机路径等等。Cygwin没有删除任何丰富的API功能,只调整了其中的一小部分。

#1


11  

If it were me, I would install the following:

如果是我,我会安装以下软件:

  • MinGW port of the GCC compiler from Twilight Dragon (this is only at 4.4.1 at present, but I'd guess it will meet your needs, and I've found it to be very reliable)

    来自《暮光之龙》的GCC编译器的MinGW端口(目前只有4.4.1,但我想它会满足您的需要,我发现它非常可靠)

  • The MSYS environment (bash etc. for Windows) from http://sourceforge.net/apps/mediawiki/cobcurses/index.php?title=Install-MSYS

    MSYS环境(Windows的bash等)来自http://sourceforge.net/apps/mediawiki/cobcurses/index.php?

  • Various tools like flex from http://gnuwin32.sourceforge.net/

    各种工具,比如来自http://gnuwin32.sourceforge.net/的flex

This is effectively the environment I do my own programming in, and it works very well. If you want an IDE, I'd recommend Code::Blocks, but both gvim and emacs are available for Windows too.

这是我自己编程的有效环境,而且运行得非常好。如果您想要一个IDE,我推荐代码::Blocks,但是gvim和emacs都可以用于Windows。

#2


4  

If you don't use any UNIX system calls so you can run on Windows freely. There are flex & bison for windows too: http://gnuwin32.sourceforge.net/packages.html . You can go ahead with MinGW: http://www.mingw.org/ .

如果不使用任何UNIX系统调用,则可以在Windows上*运行。windows也有flex和bison: http://gnuwin32.sourceforge.net/packages.html。你可以使用MinGW: http://www.mingw.org/。

If you have UNIX system calls, then you have to use cygwin: http://www.cygwin.com/ , http://en.wikipedia.org/wiki/Cygwin .

如果您有UNIX系统调用,那么您必须使用cygwin: http://www.cygwin.com/, http://en.wikipedia.org/wiki/Cygwin。

#3


1  

I very much doubt either cygwin nor mingw is up to 4.4.3 yet. I would bet on being able to upgrade the compiler in mingw to be easier.

我非常怀疑cygwin和mingw是否达到了4.4.3。我敢打赌,在mingw中升级编译器会更容易。

You'll need cygwin if you're actually using any Linux specific stuff. The libraries you listed off aren't an issue I don't think. POSIX could be, depending.

如果您实际使用任何特定于Linux的东西,您将需要cygwin。我不认为你列出的库是一个问题。POSIX可能不同。

#4


1  

A nice new alternative is Cygnal. The basic idea:

一个不错的新选择是Cygnal。它的基本思想是:

  • First, compile the code under Cygwin for Cygwin itself using its "native" toolchain (not MinGW).
  • 首先,使用“本机”工具链(不是MinGW)为Cygwin本身编译Cygwin下的代码。
  • Next, deploy the program with the Cygnal version of the Cygwin DLL.
  • 接下来,使用Cygwin DLL的Cygnal版本部署程序。

Cygnal is a fork of the primary Cygwin DLL which changes certain behaviors which are too Unix like.

Cygnal是Cygwin DLL的一个分支,它改变某些行为,这些行为太像Unix。

Cygwin's motto is "get that Linux feeling on Windows". Cygnal tones down that feeling; it brings back some of the Windows feeling to programs, so that those programs work for Windows users outside of the Cygwin environment using Windows conventions.

Cygwin的座右铭是“在Windows上感受Linux”。Cygnal缓和了这种感觉;它给程序带来了一些Windows的感觉,因此这些程序可以为Cygwin环境之外的Windows用户使用Windows约定。

Programs understand native paths, and such. None of the rich API functionality in Cygwin is removed, only a small portion of it is adjusted.

程序理解本机路径等等。Cygwin没有删除任何丰富的API功能,只调整了其中的一小部分。