C++ Makefile 3 files -


i have makefile problem. know how create makefile two, not 4 different files including header files...

there 4 files, main.cpp dictionary.h dictionary.cpp , cinco.h

cincotest: main.o cinco.o     g++ -o p3 main.o cinco.o  main.o: main.cpp cinco.h     g++ -c main.cpp  dictionary.o: dictionary.cpp dictionary.h     g++ -c .cpp   # clean clean:     rm -f p4 *.o *~ 

do need other files code or here??

if know answer , input new code perfect ;)

it looks me standard way of organizing code - .cpp , .h header file go it.

the rules have sufficient. unless main.cpp #include-s dictionary.h header file, or dictionary.cpp #include-s cinco.h, in case:

main.o: main.cpp cinco.h dictionary.h     g++ -c main.cpp  dictionary.o: dictionary.cpp cinco.h dictionary.h     g++ -c .cpp 

a makefile dependency list. each *.o file, it's dependencies source files needed compile it. if in main.cpp #include dictionary.h, change dictionary.h means main.cpp needs recompiled, of course. therefore, dependency rule indicate same way.

since you're using g++, can use g++ write dependency rules you. try:

g++ -mm -mf main.deps main.cpp 

see gcc's man page more information.


Comments

Popular posts from this blog

java - Static nested class instance -

c# - Bluetooth LE CanUpdate Characteristic property -

JavaScript - Replace variable from string in all occurrences -