Juan Carlos Arevalo Baeza wrote:
> Hi! I'm trying to move our whole development structure from exclusively
> using the Microsoft Visual C++ 6 IDE, to using a makefile-based structure.
I've moved a project from borland's IDE to g++ and makefiles. It's about
50 KLOC or 3000 person-hours of effort--the project, not the port. Yours
sounds bigger; have you read Lakos's book about large-scale C++ projects?
My first step was to replace the IDE with gnu make, while still using
borland's compiler, linker, resource compiler, and so on. Now it's
working well enough that we've completely abandoned the borland tools,
except that we still use either borland's or ms's resource compiler.
I think both are available gratis; at least the borland one is.
I haven't yet figured out how to make VERSIONINFO resources work
> We'll probably keep using the IDE for editing and debugging, though, but
Maybe for editing, but I don't think you'll be able to debug with it.
I like the gdb-5.0/insight win32 port at http://www.objectcentral.com .
Its GUI is less polished than borland's, but gdb has some great
features that more than compensate for that.
> we'll probably add support for compiling under GCC too, as a first step to
> becoming portable. I'd like to get some pointers to the most appropriate
> (in your opinion) resources on the net, and also I'd like to ask a few
The gnu make manual, of course, and this page with all its "white papers":
I've found no other resource that's useful beyond those two. Paul is the
gnu make maintainer. He's extremely good about answering make questions
in gnu.utils.help . Do read his white papers. They're crucial.
> - I have already downloaded the CygWin and MinGW packages and looked
> through them some. At the very least, I'll be using make and maybe a couple
> more tools from them, even when building with the Microsoft compiler.
> Anybody know of any problems in making this work?
Read everything at http://www.mingw.org, especially the FAQ, and get tools from
the "ported software" links. I use these gnu tools in particular:
make rm cp mv mkdir tar bzip2 grep sed diff patch
I think most of those are in Earnie's or Mikey's fileutils or diffutils.
These suffice for me; I don't really use cygwin.
Remember that gnu make treats file names as case sensitive. I found it
best to force all names to lowercase, and cygwin does make that easy:
for f in $*; do
new="`echo $f | tr '[:upper:]' '[:lower:]'`"
[ "$f" = "$new" ] || mv $f $new || exit 1
> - I'm not interested in working in a UNIX-like environment. Knowing that,
> is there any other reason why I should prefer CygWin to MinGW?
No. And mingw's licensing is more liberal, but you can read all about
that at http://www.mingw.org .
> - I'll need some good way to manage dependencies for the projects. They are
> huge (thousands of files), and entering the proper dependencies by hand
> into the makefiles is not an option. I hope there are tools to do this?
> IMHO, GCC is not good enough:
I've used gnu CPP directly to generate dependencies: that works with
the borland compiler as well as gcc.
> it generates dependencies for .o files only (not .obj),
Pipe it through a sed script. Borland uses .obj rather than .o, and
this approach worked with borland tools.
> and it cannot exclude specific directories (-MM is not good
Not sure what you mean, but it sounds like sed is the answer.
> - I'll want to compile for different hosts from Windows, eventually. I hope
> that's not a problem for MinGW's GCC? Maybe CygWin?
Cross compiling is possible but outside my personal experience.
Note that the mingw win32 binaries were built on linux.
> In case you're wondering, the main reason to plunge into the makefile
> world now is that Visual Studio just can't handle the complexity of our
> project tree anymore. It takes minutes just to load the workspace.
I think it's the right action to take. I used borland's IDE for many
years, and my reason for switching to makefiles was to be able to
use gcc. Now that I've done it, I'd never go back to using an IDE:
there are advantages that I had not anticipated.
With a GUI IDE, it's easy to change any detail, but it's hard to
see all the details at a glance. Makefiles can let you see what's
going on at any level of abstraction.
A GUI IDE seems easy to learn. Well, it's easy to learn how to do
any particular thing the IDE lets you do. But it's hard to learn
everything. And if something goes wrong because of an IDE bug,
you're really stuck. Makefiles are hard to master--the learning
curve is steep and long--but once mastered, they're liberating:
you're limited by your knowledge, not by your tools.
> Besides, the other two reasons to build customized makefiles (although
> it's a little further down the line) are to get the thing compilable for
> other platforms and to be able to generate different kinds of builds. For
> example, LIB-based vs. DLL-based, Debug vs. Optimized vs. Release, Checked
> vs. NonChecked. I already have too many "Configurations". I don't want to
> have to keep adding them all by hand every time I start a new project in
> the workspace, mind you.
I've never used the ms IDE, but I hear that it makes it very easy to
build debug vs. release builds. My makefile has
LIB-based vs. DLL-based
Debug vs. Optimized vs. Release
Checked vs. NonChecked [so far, works with borland compiler only]
Paul Smith has a white paper about this at paulandleslie.org .
If you like, I'll email you my makefiles (about 30K bytes) that
show how I've used these techniques to solve these problems.