#106198 - snowsquirrel - Mon Oct 16, 2006 7:00 pm
How do I compile an individual file? Normallay if I want to build MyFile.cpp, I just do a make MyFile.o.
But the generated makefile does not seem to have that target, though a .o:.cpp rule exists. I also tried make build/MyFile.o.
I understand basic makefiles, but not sure that the problem is here.
THanks,
~S
#106314 - snowsquirrel - Tue Oct 17, 2006 8:48 pm
looks like I will have roll my own makefile, loosely based on the generated one.
Yuck...
#106323 - Cearn - Tue Oct 17, 2006 10:11 pm
The main purpose of makefiles it to make working with multiple sources manageable. Why do you need to compile individual files anyway?
#106335 - snowsquirrel - Wed Oct 18, 2006 12:00 am
If you have to ask that, you probably won't get the answer, but here it goes anyway.
Compiling is a nice quick syntax check for the file you are currently editing. Also, say you change a comment in a *.h file that is included everywhere. Now you go back to the .c/.cpp file you are editing, and make some changes. Now when you do a make, it has to compile 45 .c/.cpp files, that include the guilty .h, where as if you had just comiled that file, nothing would have changed.
Obviously linking has to be done, and can find other errors, but linking is generally a slow procedure, and most typos and mental slips cause compile errors, not link errors.
If you work on large projects (1000 plus .cpp/.c files), compiling a single file is essential IMHO. I compile-current-file (ctrl-f7) in visual studio all day. Now my homebrew project here is a meagre 8 .cpp files right now, I have just become accustomed to compiling a single file. My editor (vim) supports building single files with a button press, too.
I probably won't get to it until the weekend, but I will post my makefile, maybe give it a whirl, see what you think.
~S