From: Simon Strandgaard Date: 2006-03-19T08:15:53+09:00 Subject: Re: incremental rebuild with Rake I have noticed that the '.exe' file sometimes is'nt being linked. What could be the reason for this? Does'nt matter if I touch .h files or .cpp files. Pretty odd. Any ideas? (maybe osx issue?) prompt> touch a.h prompt> rake (in /Users/simonstrandgaard/rake) g++ -c -o a.o a.cpp g++ -c -o main.o main.cpp g++ a.o main.o -o test.exe prompt> touch a.h prompt> rake (in /Users/simonstrandgaard/rake) g++ -c -o a.o a.cpp g++ -c -o main.o main.cpp prompt> prompt> touch a.cpp prompt> rake (in /Users/simonstrandgaard/rake) g++ -c -o a.o a.cpp g++ a.o main.o -o test.exe prompt> touch a.cpp prompt> rake (in /Users/simonstrandgaard/rake) g++ -c -o a.o a.cpp prompt> prompt> touch main.cpp prompt> rake (in /Users/simonstrandgaard/rake) g++ -c -o main.o main.cpp prompt> touch main.cpp prompt> rake (in /Users/simonstrandgaard/rake) g++ -c -o main.o main.cpp g++ a.o main.o -o test.exe prompt> prompt> uname -a Darwin case.local 7.9.0 Darwin Kernel Version 7.9.0: Wed Mar 30 20:11:17 PST 2005; root:xnu/xnu-517.12.7.obj~1/RELEASE_PPC Power Macintosh powerpc prompt> rake --version rake, version 0.5.4 prompt> ruby -v ruby 1.8.2 (2004-11-03) [powerpc-darwin7.5.0] prompt> prompt> rake -P (in /Users/simonstrandgaard/rake) rake .depend.mf rake a.o a.cpp a.h rake clean rake clobber clean rake default test.exe rake main.o main.cpp a.h rake test.exe a.o main.o prompt> prompt> cat .depend.mf # DO NOT DELETE a.o: a.h main.o: a.h prompt> cat Rakefile require 'rake/clean' require 'rake/loaders/makefile' APPLICATION = 'test.exe' CPP_FILES = FileList['*.cpp'] O_FILES = CPP_FILES.sub(/\.cpp$/, '.o') file '.depend.mf' do sh "makedepend -f- -- -- #{CPP_FILES} > .depend.mf" end import ".depend.mf" file APPLICATION => O_FILES do |t| sh "g++ #{O_FILES} -o #{t.name}" end rule ".o" => [".cpp"] do |t| sh "g++ -c -o #{t.name} #{t.source}" end CPP_FILES.each do |src| file src.ext(".o") => src end CLEAN.include("**/*.o") CLEAN.include(APPLICATION) CLEAN.include(".depend.mf") task :default => APPLICATION prompt> cat a.h #ifndef __A_H__ #define __A_H__ #include std::string test_a(); #endif // __A_H__ prompt> cat a.cpp #include "a.h" std::string test_a() { return std::string("a"); } prompt> cat main.cpp #include "a.h" int main(int argc, char **argv) { std::string s = test_a(); printf("test %s\n", s.c_str()); return 0; }