Generate Make Files (for GCC) from Visual Studio S

2020-06-01 07:09发布

问题:

I want to compile my Visual Studio Solution, with three projects, in Linux using GCC. The solution contains two DLL projects and one application(.EXE) project which uses these DLLs. The source code doesn't contain any Windows dependency.

How do I convert the solution (with 3 projects) to make files which can be compiled in Linux using GCC.

Is there is any tool for converting the Visual Studio Solution (Project) to make file/s.

The Visual Studio version is Visual Studio 2008

回答1:

Maybe this can help you, but you need to handle whit you outputs in the original code

Make-It-so

http://code.google.com/p/make-it-so/

or sln2mak

http://www.codeproject.com/Articles/28908/Tool-for-Converting-VC-2005-Project-to-Linux-Makef

i hope this can help you



回答2:

You can use i.e. vcproj2cmake or vcxproj2cmake. Further tools are already listed here: How to support both vcxproj to cmake on a project?



回答3:

First, Linux don't have DLLs, it has shared objects which can be dynamically linked, with a different semantics. Read Levine's Linkers & Loaders book for more, and the Program Library Howto and Drepper's How to write shared libraries. For C++, be aware of name mangling and see also the C++ dlopen mini-howto.

Then, I think that you should not try to convert your VS project into a Makefile, you should code a good Makefile by yourself.

Don't forget to setup your Makefile so that -Wall is passed to GCC (and perhaps also -std=gnu99, and -g if you want debugging information, probably thruCFLAGS or CXXFLAGS).

Unless your program is a million line of code application, you won't have much trouble in writing your own Makefile. I strongly suggest to learn to use GNU make and to read its documentation, which seems to me well written (with some tutorial part). You might glance at the output of make -p which gives the "builtin knowledge" of GNU make.

You could also look inside existing free software Linux applications and study their Makefile.

BTW, if you have hard time debugging your makefiles, use remake.

Don't think in terms of "converting my app to Linux" but more in terms of "coding a Linux app".

Notice that some frameworks (notably Qt) exist to develop software portably to Linux and Windows and MacOS. You might even use them for non-GUI applications.

Don't forget to read material like advanced linux programming and advanced unix programming