Multiple definition of 'main'

issue with main and all source file's functions.

Page 1 of 1

11 Replies - 10161 Views - Last Post: 28 June 2010 - 07:07 PM Rate Topic: -----

#1 fallenreaper  Icon User is offline

  • D.I.C Head

Reputation: 3
  • View blog
  • Posts: 240
  • Joined: 19-June 10

Multiple definition of 'main'

Posted 28 June 2010 - 02:44 PM

Quote

multiple markers at this line:
-multiple definition of 'main'


So, i was getting this issue when i was working on a C project. My professor gave us a project to tinker with.

Origionally it was set up as follows:
#define BITS = 12
#define HASHING_SHIFT (BITS-8)
#define MAX_VALUE (1<<BITS)-1
#define MAX_CODE MAX_VALUE -1

#if BITS ==14
  #define TABLESIZE 18041
#endif 



and i changed it to the following:
//set this up globally
unsigned int BITS,HASHING_SHIFT,MAX_VALUE,MAX_CODE,TABLE_SIZE;

int main (int argc, char *argv[]){  //<--this bracket as well as all other functions give error.
  BITS = 12;
  HASHING_SHIFT = (BITS-8);
  MAX_VALUE = (1<<BITS)-1;
  MAX_CODE = MAX_VALUE -1;



but i keep getting the error. I was unsure why, as all of the beginning brackets are throwing this error at me.

Does anyone know how to solve this issue? Ill add more code if nessicary, but that is pretty much the only thing i had changed.

Is This A Good Question/Topic? 0
  • +

Replies To: Multiple definition of 'main'

#2 NickDMax  Icon User is offline

  • Can grep dead trees!
  • member icon

Reputation: 2250
  • View blog
  • Posts: 9,245
  • Joined: 18-February 07

Re: Multiple definition of 'main'

Posted 28 June 2010 - 02:47 PM

well I would look for another instance of the symbol "main"
Was This Post Helpful? 1
  • +
  • -

#3 Oler1s  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 1395
  • View blog
  • Posts: 3,884
  • Joined: 04-June 09

Re: Multiple definition of 'main'

Posted 28 June 2010 - 02:47 PM

So what does "multiple definition of main" mean?
Was This Post Helpful? 1
  • +
  • -

#4 fallenreaper  Icon User is offline

  • D.I.C Head

Reputation: 3
  • View blog
  • Posts: 240
  • Joined: 19-June 10

Re: Multiple definition of 'main'

Posted 28 June 2010 - 02:53 PM

well, thats the thing....

It says "multiple instance of '[insert function name here]'

so i was thinking there was more to it then that...
Was This Post Helpful? 0
  • +
  • -

#5 Oler1s  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 1395
  • View blog
  • Posts: 3,884
  • Joined: 04-June 09

Re: Multiple definition of 'main'

Posted 28 June 2010 - 02:57 PM

What does multiple definition mean? Not sure? Take out the word multiple. What does definition mean, in the context of C++?

Don't know? Did you Google?
Was This Post Helpful? 0
  • +
  • -

#6 NickDMax  Icon User is offline

  • Can grep dead trees!
  • member icon

Reputation: 2250
  • View blog
  • Posts: 9,245
  • Joined: 18-February 07

Re: Multiple definition of 'main'

Posted 28 June 2010 - 03:00 PM

basically the error is stating that you have defined two functions with the same name "main" -- this often happens when people put main() into a header or try to declare main (you don't need to declare main) improperly. You litterally just have to figure out why you have two main() functions. Its like highlander -- there can be only one.
Was This Post Helpful? 1
  • +
  • -

#7 fallenreaper  Icon User is offline

  • D.I.C Head

Reputation: 3
  • View blog
  • Posts: 240
  • Joined: 19-June 10

Re: Multiple definition of 'main'

Posted 28 June 2010 - 03:04 PM

Oleris, this is for C, not C++, i know they are sort of similar, but still to me entirely different languages. >_> Learning C++ on the side
Was This Post Helpful? 0
  • +
  • -

#8 fallenreaper  Icon User is offline

  • D.I.C Head

Reputation: 3
  • View blog
  • Posts: 240
  • Joined: 19-June 10

Re: Multiple definition of 'main'

Posted 28 June 2010 - 03:13 PM

So I removed all of the function calls from the top of the file but that didnt do anything. It still says the same thing, so i just put the declarations of functions back at the top as it should be there from how C should be...... but still back to the root of our issue.

A new idea?
Was This Post Helpful? 0
  • +
  • -

#9 NickDMax  Icon User is offline

  • Can grep dead trees!
  • member icon

Reputation: 2250
  • View blog
  • Posts: 9,245
  • Joined: 18-February 07

Re: Multiple definition of 'main'

Posted 28 June 2010 - 03:22 PM

Sorry without seeing your code it is really hard to troubleshoot via guess.

Generally speaking the compiler's error are pretty good at telling you what is wrong. On occasion though errors are caused by a malformed file (i.e. misaligned brackets)

Question though - do you have two .c files in your project?
Was This Post Helpful? 2
  • +
  • -

#10 fallenreaper  Icon User is offline

  • D.I.C Head

Reputation: 3
  • View blog
  • Posts: 240
  • Joined: 19-June 10

Re: Multiple definition of 'main'

Posted 28 June 2010 - 03:38 PM

Nick, you sir are AWESOME.

In the same project file i had the source file for the code given by the prof... then i made a new source file in the same project in which i just copy and pasted in which i could MOD my files without ruining what he had done.

You sir, saved me much confusion. Stupid C-Eclipse. >_>

I guess it is one of those things that you need to be careful of when using an IDE such as this.
Was This Post Helpful? 0
  • +
  • -

#11 NickDMax  Icon User is offline

  • Can grep dead trees!
  • member icon

Reputation: 2250
  • View blog
  • Posts: 9,245
  • Joined: 18-February 07

Re: Multiple definition of 'main'

Posted 28 June 2010 - 05:45 PM

:) glad I could help. Eclipse should have a way to compile just that one file...


the reason that I use Programmer's Notepad is just so that I don't have to worry about that. But... when I have to deal with multiple files I have to make a makefile to get things to compile together which is not always "convenient".
Was This Post Helpful? 0
  • +
  • -

#12 fallenreaper  Icon User is offline

  • D.I.C Head

Reputation: 3
  • View blog
  • Posts: 240
  • Joined: 19-June 10

Re: Multiple definition of 'main'

Posted 28 June 2010 - 07:07 PM

There is... i figured that out quickly, i just thinking that it would compile stuff separately like in JAVA.... *shrug* like i said, thanks a bunch! :)
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1