Hi All,
I hope I am not doing some unusual thing. I use to work in EMACS and used GDB for running and compiling my C++ code in LINUX environment. I have to move to windows now but I do not want to leave EMACS and GDB. I installed g++ and EMACS in windows successfully but I am unable to run the program because of the makefile errors. I get the following error:
Code:
make
make: *** No rule to make target `main.o', needed by `main.exe'. Stop
I dont have any variable named CFLAGS. Can I still use the above rule you stated in your reply?
That should not matter but I noticed that you alredy have a rule
Code:
%.o : %.cpp %.h
$(CC) -c $<
This is basically the same and should work as well.
Are you shure there is a file main.cpp ? ( see the edit of my last post ).
Kurt
EDIT: Just noticed that all the all the other filenames start with a Uppercase letter. Could imagine that GNU make makes a difference between main.cpp and Main.cpp even on Windows.
Kurt
Yeah, I have a file named main.cpp in that folder.
if I compile by using "make -k"
I get the fllowing:
Code:
g++ -g -O2 -Wall -c Eulerian.cpp
In file included from Eulerian.cpp:5:
Turbulence.h:19: warning: `class turbulence' has virtual functions but non-virtual destructor
In file included from Eulerian.cpp:6:
LocalMixing.h:14: warning: `class localMixing' has virtual functions but non-virtual destructor
Eulerian.cpp: In method `void eulerian::createEul(const class util &)':
Eulerian.cpp:23: no matching function for call to `vector<double,__default_alloc_template<false,0> >::at (int &)'
Eulerian.cpp: In method `void eulerian::uniform()':
Eulerian.cpp:63: no matching function for call to `vector<eulerian::wind,__default_alloc_template<false,0> >::at (int &)'
Eulerian.cpp:64: no matching function for call to `vector<eulerian::wind,__default_alloc_template<false,0> >::at (int &)'
Does it ?
To me it only indicates that the first action was to compile the second file because you told to keep going even if there are errors ( -k )
Kurt
Thanks again.
I don't have main.h. Is that a problem? What should I do in this situation?
Thanks
You do not need the %.h prerequisite for the %.o target rule.
This is the rule you need:
Code:
%.o : %.cpp
$(CC) -c $<
Incidentally, this rule (or one functionally equivalent) is one of the built-in rules for GNU make, so you don't even need this in your makefile.
Then, you need to add rules outlining the dependencies of the particular object files on the header files, e.g.
Code:
Eulerian.o : Eulerian.h Util.h // Or whatever header files Eulerian.cpp includes
Util.o : Util.h
advectPar.o : advectPar.h
etc...
You can also use g++ to calculate the dependencies on header files for you. The GNU Make manual explains all this much more thoroughly than I can: http://www.gnu.org/software/make/manual/
Bookmarks