views:

172

answers:

5

Hi,

We have a not very complicated but big (i.e. lots of files) Visual Studio C++ Win32 Console written in C++0x standard in VS2010. It does not use any non standard code or anything (Hopefully!).

I now wanna port it to Linux. Which way is the quickest way to do it? autoconf? old-fashioned make file? any other solution?

+2  A: 

You can export a make file from Visual Studio.

Update: Actually you can't anymore, unless you have VC6 lying around

graham.reeds
thankx. any tutorial, link, key word?
MBZ
Updated as I was wrong.
graham.reeds
@graham: I don't give a dang about VS or C++, but +1 for the catchy avatar ;)
Carl Smotricz
+3  A: 

Most probably you don't need autoconf (and I suggest you don't touch it, unless you love pain), because you are not trying to be portable to a dozen of Unix flavours.

  1. Roll your Makefiles manually. It shouldn't be too difficult if you have a set of shared rules and have minimal Makefiles that just specify source files and compile options.
  2. Use GCC 4.5 as it supports more C++0x features.
Alex B
+1  A: 

STAY AWAY FROM AUTO* and configure. These are horrible IMHO.

If you can somehow get a VS 8 or 9 vcproj/sln, you can use this. I have not used it, so I can't give any advice.

If you're up to manual conversion, I would suggest something like CMake, as it's pretty easy to get ready fast enough, even for large projects.

If the project has a simple layout, you could have success using Qt 4's qmake like this:

qmake -project

It will output a qmake .pro file, which can be converted into a makefile on many platforms (using qmake). This should work okay, but not perfectly. Alternatively, you can install the Qt plugin for VS, and let it generate the pro file from an existing VS project. It will make your build system depend on Qt4's qmake, which is probably not what you want.

There are of course other things like cmake, but they will all require manual intervention.

rubenvb
+1  A: 

I would use regular make but keep it simple with default rules as much as possible. Add in dependencies as you go along.

EDIT: As in interim step, build it with mingw so that you can avoid the whole API porting issue until you have a working build in your new build mechanism.

If your console app calls win32 API functions then you have a choice between modifying all the source where it is used or writing a module that implements those functions.

In prior porting efforts of this type I tried it both ways and the latter was easier. I ended up writing only about 18 to 20 shim functions.

It was successful enough that I ended up writing an OS abstraction layer that was used on many projects that simply let me compile on Windows native, cygwin, Linux, VxWorks, etc. with trivial changes to one or two files.

(p.s. Any interest in an open source version of a C++ based OS abstraction layer? I was thinking of releasing an unencumbered version of it to the world if there's sufficient interest. It's mostly useful where BOOST is too heavy -- i.e. embedded projects.)

Amardeep
A: 

The fastest way to do it?

g++ *.cpp -o myapp

Seriously, depending on your needs, even generating a makefile might be overkill. If you're just interested in a quick and dirty "let's see if we can get a working program on Linux", just throw your code files at g++ and see what happens.

jalf