开发者

How to prepare a codebase for compiling on both Windows and Unix-based systems

I am wondering about different solutions to easily compile my cross-platform application for both windows and unix.

Right now I am using a makefile on Ubuntu, but before my codebase grows larger I'd like to perform the steps necessary to compile it on Windows, and then continue doing so regularly to see that it still works.

I'd preferably not contaminate my SVN codebase repository with multiple "makefile" solutions, su开发者_运维知识库ch as VC++ solutions and so on, I'd like a more automatic way. I tried using mingw with make for windows, but it seems my secondexpansion awesomeness doesn't work on the Windows version (or something like that). It wouldn't compile, and also complained about _winNT or something like that not being defined.

How should I prepare my codebase for cross-platform easy compiling? Things like buildtools, perhaps autogenerate VS file from makefile, or something similar. Some preprocessor magic in a stdinc file perhaps?

Thanks!


I will point you to CMake which is used by high-profile projects, such as MySQL, KDE, or Compiz.

It has the ability to generate native build files for the target system, such as Makefiles for Unix-based platforms, and Visual C++ project and solution files for Windows.

In order to deal with platform differences, I invite you to see my previous post on this subject: C++: Platform dependent types - best pattern


I would go for boost build: http://www.boost.org/doc/tools/build/doc/html/index.html

You can choose your platform and your compiler from the command line (dos command prompt on Windows) and everything else works.

e.g

bjam release gcc,

or

bjam debug msvc

You can add extra flags for each compiler (if you so wish) or different versions of the compiler.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜