Hello All!

Well this is not exactly a C++ question. Please let me know if this needs to be posted elsewhere. So, here it goes:

I have a project, cosisting of the entire buildrules in Makefiles. This has been built only on Linux. Now, i need to build it on Windows, but i don't know how to read Makefiles and figure out what all needs to be included in my project so as to build it on Windows.

Is there a tool that can perhaps generate a vcproj file(im using VC++) from a Makefile? or any other way out of this?

Any suggestions would be hepful. Thanks in advance!

Do you have to use VC++? That's the main question.

Because if you can use MinGW/GCC, then there is no problem at all because it includes a make.exe program that you can use to build your project. Of course, you'll still have to worry about all the external dependencies, making sure their include/lib paths are correctly setup for Windows (because, obviously, it is completely different from Linux). And most MinGW-oriented development environments (like DevC++, CodeBlocks, Eclipse, etc.) allow you to easily load up a makefile-based project.

However, if you have to use VC++ (version newer than VC6), then you have basically no choice but to create a new project for scratch and add all the files. Visual Studio does have some facilities to create a project from existing code, but it is still largely a manual setup from scratch. Visual C++ used to have support for makefiles, but they dropped the feature (I'm pretty sure they did so on purpose). Basically, Microsoft doesn't want any inter-operability between their products and anything else in the world, that's just one example, and a prime reason why I never end up using Visual Studio because their build system is crap and it does play nice with anything else.

Finally, are you sure the code uses makefiles? Makefiles are often the intermediate output of another build-system (because you have to be a bit masochistic to create makefiles manually for a non-trivial project). Often, you'll have a build-system like cmake, auto-conf, bjam, qmake, and others that will generate the makefiles that you use to compile the code. If that is the case, then it will be a lot easier to go from the build-system to a MSVC project / solution file, because many of these build-systems have means by which to generate VC project files directly (instead of generating makefiles).

Personally, I just maintain one build-configuration that I setup in cmake, which can generate both the makefiles required by Unix/Linux systems, or makefiles required by any non-MSVC compiler on any platform, or VC project files if trying to compile with Visual Studio on Windows. This works great (of course, you still have to worry about being able to actually compile the code on Windows, especially with the quirky MSVC compilers).

The moral of the story is that you are in for a lot of work (depending on the size of the project that you are porting), and if you need to port the project to another build-system, you might as well pick a more portable one then "VC project", one like cmake. And if you can avoid MSVC when porting onto Windows, then it's even better (MSVC might not be avoidable depending on the purpose of using that code).

Visual C++ used to have support for makefiles

It still does -- Visual Studio 2012 RC

@mike_2000_17:

Finally, are you sure the code uses makefiles? Makefiles are often the intermediate output of another build-system (because you have to be a bit masochistic to create makefiles manually for a non-trivial project). Often, you'll have a build-system like cmake, auto-conf, bjam, qmake, and others that will generate the makefiles that you use to compile the code. If that is the case, then it will be a lot easier to go from the build-system to a MSVC project / solution file, because many of these build-systems have means by which to generate VC project files directly (instead of generating makefiles).

Thanks for the reply. hmm, yes it looks like it does use makefiles. I tried to read through them and figure out the build rules, but had a hard time doing that. Also, i need to use VC++.

@Ancient Dragon:

Wow, cool. I will check this option out! Thanks!

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.