6

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.

thiton
  • 35,651
  • 4
  • 70
  • 100
machinarium
  • 631
  • 6
  • 17
  • Has this project actually been ported to Linux? Or are you just crossing your fingers and hoping it will compile? Because even if the build system "just worked" (tm), that's no guarantee that the code will actually compile and / or link correctly. – Chris Eberle Nov 10 '11 at 03:13
  • No, this project hasn't been ported to Linux yet? And I'm not going to do this. I want to develop under windows, and autobuild on linux. – machinarium Nov 10 '11 at 04:07
  • Heh, sorry, that's a pipe dream. Unless you're using totally cross-platform libraries (boost, qt, etc), making zero system calls (it's probably happening and you don't even realize it), and a cross-platform build system (like cmake), this simply isn't ever going to happen. Getting C / C++ projects to be cross-platform is usually quite a chore. Also I'm not sure what "autobuild" means in this context. A compile farm? automake? – Chris Eberle Nov 10 '11 at 05:59
  • Hm, "Autobuild" means the build can be done using a script(e.g. makefile). – machinarium Nov 10 '11 at 06:04
  • That's not autobuild. That's make. And there are many many flavors of it. You should really look at cmake, it can generate both linux makefiles and visual studio projects. However as I hope I've emphasized, this is no guarantee that the code will actually compile on the other architecture. – Chris Eberle Nov 10 '11 at 06:07
  • OK. I WILL CHECK cmake. Can it make translation between them(makefile and vs project property files)? – machinarium Nov 10 '11 at 12:37
  • OK THAT IS GOOD to hear. And no, it can't translate between the two. You create [CMakeLists](http://www.cmake.org/cmake/help/examples.html) files and then it translates that into something more recognizable to the current platform. – Chris Eberle Nov 10 '11 at 16:04
  • So, I need to write the CMakeLists.txt file according to the vs. project files manually. Hope tools can do it automatically. – machinarium Nov 11 '11 at 04:00

2 Answers2

1

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.

thiton
  • 35,651
  • 4
  • 70
  • 100
1

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.

Paul Michalik
  • 4,331
  • 16
  • 18