strange multiple definition of `login_user_login'

R

Robert Mens

Hi,

My compiler/linker gives me the strangest error:

process.o(.text+0x0): In function `login_user_login':
: multiple definition of `login_user_login'
login.o(.text+0x0): first defined here
collect2: ld returned 1 exit status
make: *** [imserver] Error 1

I only have this function defined once:

this is my login.c file
-----------------------------------------------------------------
/*
** login.c - handles the login requests from servers
*/

#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include "mysql.h"

void login_user_login(char * username, char * password)
{
if (mysql_user_login(username, password) == 1)
{
printf("Access denied for user %s\n", username);
}else{
printf("User %s logged in\n", username);
mysql_user_setstatus(username, "online");
}
}
-----------------------------------------------------------------

this is my login.h file for including from other source files:

void login_user_login(char * username, char * password);

I did this this way in my project and never encountered that error...
Also, it only happens when i do a make clean; make, thus when the whole
source gets recompiled instead of just login.o

If i do a make "clean; make" and then adjust the login_user_login in login.c
to something different en then "make" the program works fine!?!?

Anyone knows the solution?

Thanks in advance,

Robert
 
N

nobody

Robert Mens said:
Hi,

My compiler/linker gives me the strangest error:

process.o(.text+0x0): In function `login_user_login':
: multiple definition of `login_user_login'
login.o(.text+0x0): first defined here
collect2: ld returned 1 exit status
make: *** [imserver] Error 1

I only have this function defined once:

this is my login.c file
-----------------------------------------------------------------
/*
** login.c - handles the login requests from servers
*/

#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include "mysql.h"

void login_user_login(char * username, char * password)
{
if (mysql_user_login(username, password) == 1)
{
printf("Access denied for user %s\n", username);
}else{
printf("User %s logged in\n", username);
mysql_user_setstatus(username, "online");
}
}
-----------------------------------------------------------------

this is my login.h file for including from other source files:

void login_user_login(char * username, char * password);

I did this this way in my project and never encountered that error...
Also, it only happens when i do a make clean; make, thus when the whole
source gets recompiled instead of just login.o

If i do a make "clean; make" and then adjust the login_user_login in login.c
to something different en then "make" the program works fine!?!?
I would bet all my money on linker. Though you didn't post arguments passed
to compiler, from diagnostics it's clear you are linking 2 files: process.o
and
login.o. You didn't supply source file which resulted in process.o either.
Likely
that source file contains definition of problematic function (either
"directly",
or "indirectly" /via #include "login.c"/ - check for typo), or another
object
with the same name.
 
R

Robert Mens

nobody said:
Robert Mens said:
Hi,

My compiler/linker gives me the strangest error:

process.o(.text+0x0): In function `login_user_login':
: multiple definition of `login_user_login'
login.o(.text+0x0): first defined here
collect2: ld returned 1 exit status
make: *** [imserver] Error 1

I only have this function defined once:

this is my login.c file
-----------------------------------------------------------------
/*
** login.c - handles the login requests from servers
*/

#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include "mysql.h"

void login_user_login(char * username, char * password)
{
if (mysql_user_login(username, password) == 1)
{
printf("Access denied for user %s\n", username);
}else{
printf("User %s logged in\n", username);
mysql_user_setstatus(username, "online");
}
}
-----------------------------------------------------------------

this is my login.h file for including from other source files:

void login_user_login(char * username, char * password);

I did this this way in my project and never encountered that error...
Also, it only happens when i do a make clean; make, thus when the whole
source gets recompiled instead of just login.o

If i do a make "clean; make" and then adjust the login_user_login in login.c
to something different en then "make" the program works fine!?!?
I would bet all my money on linker. Though you didn't post arguments
passed to compiler, from diagnostics it's clear you are linking 2 files:
process.o and
login.o. You didn't supply source file which resulted in process.o either.
Likely
that source file contains definition of problematic function (either
"directly",
or "indirectly" /via #include "login.c"/ - check for typo), or another
object
with the same name.

Made a typo
login.c instead of login.h
 
N

Nick Austin

Hi,

My compiler/linker gives me the strangest error:

process.o(.text+0x0): In function `login_user_login':
: multiple definition of `login_user_login'
login.o(.text+0x0): first defined here
collect2: ld returned 1 exit status
make: *** [imserver] Error 1

My guess would be that there is a definition for login_user_login
inside process.c

Nick.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top