3

Have been developing a Visual Studio (2012) C++ project and wondered what would be the most convenient way of being able to copy it over to Linux so that I could re-compile the whole project there? Assume the C++ is platform-independent.

Would it be a case of copying all the .h and .cpp files manually in to one folder, copy that folder to Linux and then somehow creating a script (makefile?) which controls how the files are compiled? I'm not too sure if a makefile is what I require- but any mechanism so that I can compile the whole project from one command on the terminal?

user997112
  • 25,084
  • 34
  • 143
  • 278

2 Answers2

1

For the physical part, the easiest solution is to just grab the sources from your Version Control System. That will take care of the \r\n -> \n translation in your .cpp and .h files.

On the linux side, pretty much any build tool is superior to raw make. make is really the assembly language of build systems; your tool might produce a makefile as an intermediary but don't try to maintain that.

MSalters
  • 159,923
  • 8
  • 140
  • 320
  • Depends on the complexity of the build process. If it's just a matter of throwing a compiler at all the .cc files in one go, a makefile might be the simplest approach. – jalf Feb 05 '14 at 10:22
1

Yes, copy the files (or as @MSalters says - checkout a fresh copy) then construct an alternative .vcxproj for the Linux build tools. Note that the Visual Studio project file is really just a very fancy type of makefile.

A makefile at its simplest is just a list of files (or file types even) and a command for running on them. Once you have that written up, building is as simple as running MSBuild against a .sln file.

So you need to decide which build system to use on Linux - there's CMake which is a makefile-generator, and several other systems available.

Someone has made a tool that parses the VS project file and can generate a makefile from it, but it doesn't support VS2012 (you can fix this though, contribute)

gbjbaanb
  • 49,287
  • 10
  • 99
  • 143