I have a Visual Studio project that uses a solution file to build it. I want to generate a makefile so that I can build it using the makefile instead of the solution file. (The reason I need to do this in case you are wondering is that I am incorporating my project into a larger software system that uses makefiles to build, and I want to be able to build the whole thing using the makefiles.)
Is there a way to aut开发者_运维技巧omatically get the information from the Visual Studio solution and convert it into a makefile format, or do I need to do that manually?
This used to be possible in VC6, it had an option to generate a makefile from a .dsp project file. No more, the build process has changed too much to make this achievable.
Not a real problem, you can have the makefile invoke the vcbuild.exe tool, it builds a .vcproj project. Important switches you'll want to use in your makefile:
- /clean: use that in your clean: target
- /rebuild: use in your rebuild: target
- /nocolor: makes build output look battleship gray like other build tools
- /platform: selects the configuration you want to build (e.g: /platform:win32)
For example:
vcbuild /platform:win32 example.vcproj release
Note that the build system got a major revision in VS2010, you'll use msbuild.exe instead to build the .vcxproj project.
Although I never used it, this might be an alternative. It's rather old and might not work well for new projects. It used to come with mingw but (don't know why) not anymore. Offtopic: Personally, if the project is not enormous, I would go with manually writing a Makefile.
Good advice - Avoid wasting a couple of days on tools for a job that'll take a few hours at most. They guy who built my first house had one 30 year old table saw and built the whole house iwth it. I now have at least 10 saws and never build anything.
精彩评论