473,385 Members | 1,267 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

: multiple definition of `main'

a
Don't know why this compilation generated, I'm sure no 2 mains exist:

make votei
gcc vote.c datamanager.c -o votei vote.c -L. -lhungarian
vote.c: In function `main':
vote.c:254: warning: passing arg 2 of `hungarian_init' from incompatible
pointer type
vote.c: In function `main':
vote.c:254: warning: passing arg 2 of `hungarian_init' from incompatible
pointer type
/tmp/ccsVGl95.o(.text+0x0): In function `main':
: multiple definition of `main'
/tmp/ccSVKJyx.o(.text+0x0): first defined here
collect2: ld returned 1 exit status
make: *** [votei] Error 1
Makefile:
CC = gcc
AR = ar

CFLAGS = -O3 -Wall -I.
LDFLAGS = -L. -lhungarian

all: libhungarian.a hungarian_test

votei: vote.c datamanager.c $(HUNGARIANLIB)
$(CC) $(CFLAGS) vote.c datamanager.c assignmentoptimal.c -o $@ $<
$(LDFLAGS)

votei: vote.c datamanager.c $(HUNGARIANLIB)
$(CC) vote.c datamanager.c -o $@ $< $(LDFLAGS)

why comp.lang.c faq hasn't covered compilation topic? Where should I go for
more information?
Nov 28 '07 #1
11 9222
a wrote:
Don't know why this compilation generated, I'm sure no 2 mains exist:
You may be sure of this fact, but gcc seems to disagree. It would be
much easier to figure out whether you or gcc is right, if you had
actually bothered to give us copies of your code.
Nov 28 '07 #2
a wrote:
Don't know why this compilation generated, I'm sure no 2 mains exist:
<snip>
/tmp/ccsVGl95.o(.text+0x0): In function `main':
: multiple definition of `main'
/tmp/ccSVKJyx.o(.text+0x0): first defined here
collect2: ld returned 1 exit status
make: *** [votei] Error 1
<snip>

The above message clearly shows that two different object files are
exporting main() and therefore the linker is unable to decide which one
to use.

I am guessing that there is some mistake somewhere in your makefile or
conditional compilation directives that is allowing this to happen.

Without more information and relevant code we really cannot say anything
further.
why comp.lang.c faq hasn't covered compilation topic? Where should I
go for more information?
The comp.lang.c FAQ does not cover "compilation" because the details are
inherently implementation specific and this group tries to restrict
itself to Standard C. There are simply too many compilers with too many
idiosyncrasies to deal with in a FAQ.

You should ask for help in a group devoted to your platform or compiler.
GCC has several groups among which is <news:gnu.gcc.help>.

Nov 28 '07 #3
a wrote:
Don't know why this compilation generated, I'm sure no 2 mains exist:

make votei
gcc vote.c datamanager.c -o votei vote.c -L. -lhungarian
You have vote.c TWICE in the command line. Hence you define
main twice...

--
jacob navia
jacob at jacob point remcomp point fr
logiciels/informatique
http://www.cs.virginia.edu/~lcc-win32
Nov 28 '07 #4
In article <5e**********************************@b40g2000prf. googlegroups.com>,
<ja*********@verizon.netwrote:
>a wrote:
>You may be sure of this fact, but gcc seems to disagree. It would be
much easier to figure out whether you or gcc is right, if you had
actually bothered to give us copies of your code.
Actually, he gave us all the information we need, as Jacob spotted.

-- Richard
--
"Consideration shall be given to the need for as many as 32 characters
in some alphabets" - X3.4, 1963.
Nov 28 '07 #5
Richard Tobin wrote:
In article <5e**********************************@b40g2000prf. googlegroups.com>,
<ja*********@verizon.netwrote:
a wrote:
You may be sure of this fact, but gcc seems to disagree. It would be
much easier to figure out whether you or gcc is right, if you had
actually bothered to give us copies of your code.

Actually, he gave us all the information we need, as Jacob spotted.
You're right - I should have read more carefully.

Still, he should have provided source code, just in case the problem
was in the code itself, and not on the command line.
Nov 28 '07 #6
a
Yes you are right. It is nothing dealt with the codes...
Nov 29 '07 #7
jacob navia wrote:
a wrote:
>Don't know why this compilation generated, I'm sure no 2 mains exist:

make votei
gcc vote.c datamanager.c -o votei vote.c -L. -lhungarian

You have vote.c TWICE in the command line. Hence you define
main twice...
Well spotted.
Nov 29 '07 #8
a wrote:
>
Yes you are right. It is nothing dealt with the codes...
Meaningless. See below.

--
If you want to post a followup via groups.google.com, ensure
you quote enough for the article to make sense. Google is only
an interface to Usenet; it's not Usenet itself. Don't assume
your readers can, or ever will, see any previous articles.
More details at: <http://cfaj.freeshell.org/google/>

--
Posted via a free Usenet account from http://www.teranews.com

Nov 29 '07 #9
On Nov 29, 12:18 am, Mark McIntyre <markmcint...@spamcop.netwrote:
jacob navia wrote:
a wrote:
Don't know why this compilation generated, I'm sure no 2 mains exist:
make votei
gcc vote.c datamanager.c -o votei vote.c -L. -lhungarian
You have vote.c TWICE in the command line. Hence you define
main twice...

Well spotted.
I suppose it's out of the question for gcc to detect duplicate source
filenames? (Comparing 2 filespecs is that trivial but for something as
sophisticated as gcc?..)

Bart
Nov 29 '07 #10
Bart wrote:
>
On Nov 29, 12:18 am, Mark McIntyre <markmcint...@spamcop.netwrote:
jacob navia wrote:
a wrote:
>Don't know why this compilation generated, I'm sure no 2 mains exist:
>make votei
>gcc vote.c datamanager.c -o votei vote.c -L. -lhungarian
You have vote.c TWICE in the command line. Hence you define
main twice...
Well spotted.

I suppose it's out of the question for gcc to detect duplicate source
filenames? (Comparing 2 filespecs is that trivial but for something as
sophisticated as gcc?..)
While this is OT here, what happens with something like:

gcc file.c -DSOMETHING file.c

Perhaps file.c will compile differently in the second case, due to
SOMETHING now being defined. (Not that I'm advocating this to be
good practice in a real-world environment, mind you.)

--
+-------------------------+--------------------+-----------------------+
| Kenneth J. Brody | www.hvcomputer.com | #include |
| kenbrody/at\spamcop.net | www.fptech.com | <std_disclaimer.h|
+-------------------------+--------------------+-----------------------+
Don't e-mail me at: <mailto:Th*************@gmail.com>
Nov 29 '07 #11
In article <47***************@spamcop.net>,
Kenneth Brody <ke******@spamcop.netwrote:
>Bart wrote:
>>
On Nov 29, 12:18 am, Mark McIntyre <markmcint...@spamcop.netwrote:
jacob navia wrote:
a wrote:
Don't know why this compilation generated, I'm sure no 2 mains exist:

make votei
gcc vote.c datamanager.c -o votei vote.c -L. -lhungarian

You have vote.c TWICE in the command line. Hence you define
main twice...

Well spotted.

I suppose it's out of the question for gcc to detect duplicate source
filenames? (Comparing 2 filespecs is that trivial but for something as
sophisticated as gcc?..)

While this is OT here, what happens with something like:

gcc file.c -DSOMETHING file.c

Perhaps file.c will compile differently in the second case, due to
SOMETHING now being defined. (Not that I'm advocating this to be
good practice in a real-world environment, mind you.)
Right - that's the counter-example. It is certainly possible to create
a fully conforming situation where something would be broken if the
compiler refused to do what it is told.

Nov 29 '07 #12

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

11
by: Georg Teichtmeister | last post by:
Hello! We are developing a math - library for realtime applications and want to use some given mathlibraries as base(ipp, MTL, .. ). Our library is a wrapper for those and you should be able to...
9
by: Daniel Moree | last post by:
I'm using MS VC++ 6.0 I'm working on a big project. I've currently have several files for this project. Here's the problem. I have one header file phead.h I have two code files main.cpp and...
5
by: Charles L | last post by:
Can someone explain to me what the following means? "C permits multiple definitions of a variable in any given namespace, provided the definitions are the same and it generates only a single...
2
by: Panda2 | last post by:
I'm getting multple definition errors for the struct in the following, and I don't know how to get around it. I've tried using extern (which I don't really understand) but it didn't help (maybe...
5
by: Tony Johansson | last post by:
Hello Experts! I just play around just to try to understand this about multiple inheritance. You have all the class definition below and at the bottom you have the main program. So here I...
10
by: PCHOME | last post by:
Hi! Would someone please help me thess C error(in gcc on Linux)? The compiler continues to give me: readLP.o: In function `Input_Problem': readLP.o(.text+0x0): multiple definition of...
3
by: Student | last post by:
Hi all, While compiling a program I had this message : tools.o(.data+0x0): multiple definition of `VAR_1' main.o(.data+0x0): first defined here tools.o(.data+0x4): multiple definition of...
4
by: chandu | last post by:
Hello, I had one doubt,please clarify it. Main is the entry point for the application. if i had multiple overloaded main methods in my application. how the compiler recognizes the original...
3
by: Antonio Rivas | last post by:
Hello all. I've got a problem of multiple definition in a program that at first glance looks correct (I won't type the whole code, just the relevant one and as examples since seems is a linkage...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.