I have a visual studio-2010 project which contains lots of source files and header files. Now I need to autobuild this project under the latest Debian GNU/Linux. So I choose to use MinGW. But I need a makefile of this visual studio project. Is there a easy way to translate a vs project into a makefile? Or MinGW can directly build a visual studio project with additional packages or libraries? Any ideas will be appreciated.
2 Answers
If you want to port building of your program permanently to GNU/Linux, I'd recommend to switch to the autotools (autoconf and automake). The autotools are very widespread and have excellent cross-compilation support. (on the other hand, also a somewhat earned reputation for weirdness.) While there is no auto-translation from VS projects I'm aware of, compilation of a single program can be as simple to set up as finding all source and header files, listing them in the Makefile.am appropriately and writing a rule for Windows objects.
If the transition to MinGW isn't written in stone or a continuing two-compiler build scenario is likely, go with cmake like the commenters suggested. While I've always found CMake to be a major pain for non-maintainer builds (common for open-source software), it has a good reputation for generating all kinds of build description files like Makefiles and VS projects.
One way or the other, you'll have to convert your project by hand. It can be quite easy for a normal project structure, but it has to be done.
I do not know of any tool-chain which is capable of doing this out of the box. CMake (and all the other meta makefile generators) only offer a one-way conversion: they can generate a Visual Studio project/solution once, but there is no way to automatically synchronize with changes made in VS/MSBuild configurations. Writing and maintaining CMake (or PreMake or whatever) configurations is a pain and it only makes sense, if your primary development platform is anywhere outside the Microsoft platform.
There is an interesting alternative though: xbuild - a port of MSBuild which is the build system behind the intelligence of VS. Theoretically, one could extend the system to support MSBuild configurations generated by Visual Studio and define conversion rules for proper C++ tool-chains on other platforms (even in a two-way manner). The declarative, XML based nature of MSBuild/XBuild is a huge win compared to autotools/make which have costed me far too much time and inconvenience in my developer's life. MSBuild/XBuild are both implemented as a purely managed framework with well designed architecture so that extensions are quite easy to implement. Of course, this only pays off if you (or your company) are seriously thinking about large scale cross platform support.