Convert a makefile to a VS project

2019-01-23 13:53发布

I have a few makefiles to build certain libraries for me. I now need to convert them to a VS project for convenience sake. I googled only to find the ways to convert a VS project to a makefile with the help of makefile wizard provided by VS. Also, I did find that there was this feature included in VS6 to convert the makefile into VS project. But this feature has been removed for the later versions. Also, I realized that VS6 downloads are no more available on the msdn site.

Is there any other way to convert a makefile to a visual studio project? or Can I get hold of VS6 from somewhere?

2条回答
走好不送
2楼-- · 2019-01-23 14:22

The only real option you have here is to manually do the conversion (or use the Makefile Project Wizard). You say you have 'a few' makefiles, don't know how much that is, but unless you're talking about > 10 or so it's not that much work to manually create a Visual Studio project for these. After all, all you do is create a new dll project and add source files to it. The default compiler/linker flags hardly need any tweaking. Oh yeah if you do tweak them, make sure to do those changes in a property sheet instead of in the project itself: the property sheet can be reused by other projects, it's a simple matter of the DRY principle.

Why is this the only real option? Firstly there is no tool that can reliably convert any arbitrary makefile to a VS project, simpy because makefiles can be in any format you want and a lot of their functionality simply has no counterpart in a VS project. Secondly, VS6 is at this date about 15 years old so even if you get it to run on your machine, the output it produces is still ancient and definitely not what you want to use for your projects.

查看更多
干净又极端
3楼-- · 2019-01-23 14:30

This CodeProject article : Automatically Translate makefile C/C++ Project for Visual Studio offers a rudimentary solution aiming for VS 2013 C/C++ projects.

[ PS: not my article, but it addresses at least the main part of your VS6 question. ]

It is a simplistic script, and therefore fraught with assumptions and opportunities for failure. It may, however, give you a starting point that is workable, if your project fits within its domain of intent.

You will still need to:

  • include files that aren't obviously C/C++ files
  • adjust any project options
  • adjust any compiler options
  • add link time dependencies
  • etc.

In case that article goes away ... it is a VBS script that:

  • scans the directory for files that have extensions belonging to known VS groups
  • recurs into sub directories looking for more files.
  • creates the .vcxproj and .vcxproj.filters files
  • adds the found files to the .vcxproj and .vcxproj.filters files

So, if you have nested projects (likely) you will need to tweak how the script works in its recursion step.

Good luck.

查看更多
登录 后发表回答