linker error - Multiply defined section
Login to reply to this topic.
Wed, 2007-05-09 13:54
Joined: 2007-05-09
Forum posts: 2
Hello, I am a relatively new symbian developer and I have troubles with one of my classes. It is a small and not very well thought class for debugging:
Code:
#ifndef DEBUGCLASS_H
#define DEBUGCLASS_H


#include <e32std.h>
#include <flogger.h>

class DebugClass {
public:
DebugClass();
~DebugClass();
void write(const TDesC& text, TInt logLevel = 0);
void incLevel();
void decLevel();
void writeStart(const TDesC& text, TInt logLevel = 0);
void writeEnd(const TDesC& text, TInt logLevel = 0);

private:
//the enum hack
enum { bufferSize = 2000, levelIndent = 2, maxLevel = bufferSize / levelIndent };
RFileLogger logger;
TBool canWrite;
TInt level;
TInt defaultLogLevel;
TBuf8<bufferSize> buffer;
};

#endif

The class is thought to provide some kind of call stack for on device debugging. At the begging of a function you may place a writeStart()  (with a corresponding writeEnd() at the end), a write() anywhere else and get a nice formated output.

The error I get at compilation is:

Quote
mwldsym2.exe: Multiply defined section: DebugClass::DebugClass(void) (??0DebugClass@@QAE@XZ) in
mwldsym2.exe: files DebugClass.o, DebugClass.o
mwldsym2.exe: Multiply defined section: DebugClass::~DebugClass(void) (??1DebugClass@@QAE@XZ) in
mwldsym2.exe: files DebugClass.o, DebugClass.o
[and so on]

I used it with some succes in another project (but still I had troubles with making it compile). When the 2 files (.h and .cpp) were placed in their own folder it also had errors, so there must be something with my files that the linker does not like, since errors appeared in both projects.
I can also provide the implementation code if necessary, since it is not a secret.

Wed, 2007-05-09 14:14
Joined: 2004-11-29
Forum posts: 1419
weird error.  It lists the same .o name twice in the error message.

Have you maybe accidently duplicated the code, and have two "SOURCE" lines in your mmp, useing the same file from two different locations or something?


If not, I would shut down everything, remove all intermediate files manually (normally under \epoc32\BUILD\ or somewhere in your project directory).
Then reboot the computer and re-import the project and rebuild...
Have lost count of the times I have had to do something like that because some file got messed up somewhere in the build system..

Can't see anything obviously wrong with your class declaration...
except possibly the creative use of that enum Smiley (but nothing wrong, just a bit.. weird Smiley)
Wed, 2007-05-09 14:56
Joined: 2007-05-09
Forum posts: 2
Well, it seems I have entered the forum with the right foot  Grin

Indeed, it was the user and not the tools. Staring again at the mmp file I found that DebugClass.cpp was included twice.
I will look again at the old project, to see what was the problem with that one.

Thanks alh

copyright 2003-2009 NewLC SARL