Using makefile - 'Multiple Definition' compile errors
As part of an assignment, our class was given a small set of c++ classes which are compiled using a makefile.
As part of the assignment, I have created a namespace and saved in it a .cpp file. The functions, constants and typedefs from the namespace are now used in one of the original files, and so I added an <#include MyFile.cpp> to the file I modified, in addition to a using MyNamespace; When I try to use the original makefile, the compiler gives a lot of errors about multiple definitions of every function in the namespace. What do I need to do to resolve this? Do I need to change the makefile or one of the files themselves? I am new to Linux programming and makesfiles. I can post the actual files if needed. |
Hi OnlySolitaire,
The Programming forum would have likely been a better choice. (Many Linux users know very little or even no programming, and this isn't really a Linux-newbie question) In any case, it is hard to tell exactly what is going on without seeing the source for your makefile, cpp files, hpp files, and the errors. Perhaps use pastebin or something similar for that. |
Quote:
If you created a header file to be included by other cpp files, then 99% of the time, it should be included like this: Code:
#include "MyFile.hpp" Also, by convention, headers have a "hpp" extension and contain only #defines, class definitions, and other data type definitions--no executable code (i.e. functions) at all. Again, by convention, a header file should have something like this: Code:
#ifndef MYFILE_HPP |
All times are GMT -5. The time now is 05:12 PM. |