LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   Make files (https://www.linuxquestions.org/questions/programming-9/make-files-388344/)

disruptive 12-01-2005 01:08 PM

Make files
 
I have recently pushed all my files into sub directories. I wish to be able keep them there in an organised fashion. However I am having trouble getting a makefile to do this job, currently I have in each subdirectory the header file and .cpp file associated with that unit of functionality.

I have this type of arrangement here:

all: Sim

Sim: .Energy.o Sorts.o FileHandling.o MyMatrix.o BeadBead.o Cell.o Display.o Initialize.o Translation.o Clash.o MyRandom.o MC.o

g++ -o Sim Energy.o Sorts.o FileHandling.o MyMatrix.o BeadBead.o Cell.o Display.o Initialize.o Translation.o Clash.o MyRandom.o MC.o


Energy.o: Energy.cpp

g++ -c -Wno-deprecated Energy.cpp


I have tried the usual ../Energy/kjhkdh.cpp but this does not seem to work. How can I do this easily and simply. I dont mind where the object files end up, but would like the executable in the main directory.

Thanks

gruby12 12-01-2005 02:06 PM

Maybe try to use -o option of g++.

Regards Janusz

disruptive 12-02-2005 02:52 AM

what do you do you have an example?

gruby12 12-02-2005 02:59 PM

-o option gives name and location of executable file.

Janusz

disruptive 12-02-2005 03:02 PM

i am not sure what you mean?

ta0kira 12-02-2005 09:33 PM

Just remember that everything is relative to the current execution path of the makefile. If you have a dependency that is not in the same path, you need to specify the path in the dependency list. Maybe you need this?
Code:

Sim: Energy/Energy.o #...
        g++ -o Sim Energy/Energy.o #...

#...

Energy/Energy.o: Energy/Energy.cpp
        g++ -c -Wno-deprecated Energy/Energy.cpp -o Energy/Energy.o

ta0kira


All times are GMT -5. The time now is 07:10 PM.