0

I have a project in C++ (including OpenMP) created in Visual Studio 2012. Which is please the easiest way to create makefile files and project which could be executed in Linux?

kennySystemExit
  • 329
  • 2
  • 5
  • 22
  • 1
    I have not tested it, but have a look at http://www.cmake.org/Wiki/CMake#Visual_Studio – Erbureth Jun 23 '14 at 13:59
  • Some of those CMake generators create loads of functions and macros to support all compiler options of visual studio so that the CMakeLists.txt can accurately regenerate the Visual Studio project file. I would expect the ones that do that to be not desired for a linux makefile. – drescherjm Jun 23 '14 at 14:11
  • At least it will be a place to start. – Erbureth Jun 23 '14 at 14:23
  • I would use CMake for this but create my CMakeLists.txt myself (instead of using a convertor) and use the CMakeLists.txt to generate gcc makefiles under linux and also to generate Visual Studio projects getting rid of the original Visual Studio projects. – drescherjm Jun 23 '14 at 19:13
  • @drescherjm Yes, that whould be preferable, however it is usable only if the project is not too large. – Erbureth Jun 24 '14 at 07:26

1 Answers1

1

My suggestion is to write your Makefile manually. Unless your project is huge (e.g. million lines of source code), it is actually quite easy. This and that and that examples should help.

Caveat: the tab character is significant in Makefile-s. Use a good editor knowing that (e.g. emacs)

And GNU make has a good documentation with a tutorial section.

You probably need to add -fopenmp to your CXXFLAGS (or compile & link with CXX=gcc -fopenmp)

PS: cmake is (like automake) a Makefile generator. Very often, it is easier to write them (i.e. Makefile-s) by hand.

Community
  • 1
  • 1
Basile Starynkevitch
  • 223,805
  • 18
  • 296
  • 547
  • While I agree on the bottom line, I wouldn't say that `GNU make has a good documentation`: I find it particularly unreadable for the beginner, it is more a reference manual. To read once you have the basic knowledge. And I don't see any "tutorial" section in it. Also check out [this question](http://stackoverflow.com/questions/2176427/). – kebs Jun 23 '14 at 16:09