Keil Logo Arm Logo

Discussion Forum

Getting error of multiple public defination.

Next Thread | Thread List | Previous Thread Start a Thread | Settings

Details Message
Read-Only
Author
Zakir Hussain
Posted
6-Sep-2012 06:00 GMT
Toolset
C51
New! Getting error of multiple public defination.

I have done a program with keil,getting error while linking. but the same program is running in single file, i think problem with linking only...up to me,i linked the program..i dont know why is not linking...can any body suggest me.

MAIN FILE:-

#include <REGX51.H>
#include "lcd.c"

unsigned int i=0,l=0;
sbit alsen=P2^0;
sbit eyesen=P2^2;
sbit Buz=P0^2;
sbit motor=P0^4;

void timer_init()
{ IE=0x82; TMOD=0x01; TH0=0x4B; TL0=0xFD; TR0=1;

}

void main()
{ unsigned int j;

lcd_init(); timer_init(); Buz=1; motor=1; delay(65000); delay(65000);

while(1) { if(alsen==1) { lcd_cmd(0x80); lcd_str("Alcohol Detected"); lcd_cmd(0xc0); Buz = 0; motor=0; while(1);

} else if(alsen==0) { lcd_cmd(0x80); for(j=0;j<1000;j++); lcd_str("Alcohol Normal "); lcd_cmd(0xc0);

}

if(l==100) { if(i>20) { lcd_cmd(0xc0); for(j=0;j<500;j++); lcd_str("I Blink Normal"); lcd_cmd(0x80);

l=0; i=0; } else { lcd_cmd(0xc0); for(j=0;j<500;j++); lcd_str("I Blink Abnormal"); Buz = 0; motor=0;

lcd_cmd(0x80); l=0; i=0; while(1); }

} if(eyesen==1) { i++;

} }
}

LCD.C:-(lcd.c)

#include<REGX51.h>

sbit rs=P3^5;
sbit rw=P3^6;
sbit en=P3^7;

void delay(unsigned int d)
{ while(d--);
} void lcd_data(unsigned char c)
{ P1=c; rs=1; rw=0; en=1; delay(150); en=0;
} void lcd_cmd(unsigned char c)
{ P1=c; rs=0; rw=0; en=1; delay(150); en=0;
} void lcd_str(unsigned char *s)
{ while(*s) { lcd_data(*s); s++; }
}

void lcd_init()
{ lcd_cmd(0x38); lcd_cmd(0x0c); lcd_cmd(0x01); lcd_cmd(0x80);
}

Read-Only
Author
Per Westermark
Posted
6-Sep-2012 06:44 GMT
Toolset
C51
New! RE: Getting error of multiple public defination.

So it isn't linking. Any reason then why you don't post the messages you get from the linker? Or exactly how did you decide that you have a problem with the linking step?

Read-Only
Author
Zakir Hussain
Posted
6-Sep-2012 06:53 GMT
Toolset
C51
New! RE: Getting error of multiple public defination.

becoz program is running fine when include all in one single file....i dont know the reason why that error is occured....

Read-Only
Author
Zakir Hussain
Posted
6-Sep-2012 07:04 GMT
Toolset
C51
New! RE: Getting error of multiple public defination.

Getting this waring also, i have defined all function in lcd.c...bt why this????

** WARNING L16: UNCALLED SEGMENT, IGNORED FOR OVERLAY PROCESS SEGMENT: ?PR?LCD_INIT?LCD

*** WARNING L16: UNCALLED SEGMENT, IGNORED FOR OVERLAY PROCESS SEGMENT: ?PR?LCD_STR?LCD

Read-Only
Author
Per Westermark
Posted
6-Sep-2012 07:22 GMT
Toolset
C51
New! RE: Getting error of multiple public defination.

One thing you should consider is actually looking for the definition of warning L16. Did you ever consider trying Google with the search string "keil warning l16"?

But next thing is that your original post have a subject claiming you get "Getting error of multiple public defination [sic!]". But even after I noted that you somehow forgot to post these error messages, you managed a new post without still having cut/pasted the linker error messages you got.

Don't you think that the linker emits specific error messages for the purpose of telling the user specific things? And if you ask for help and don't show the specific error messages, we - as readers - will not get that specific information that the linker considered important to report about?

The linker messages about multiple public definitions isn't just a random text. The linker specifically tells what exact problems it is seeing. My guess - all I can do is guess, since you refuse to post enough information - is that you have placed variables in a header file. So the linker will then see variables with same name in the resulting object files from each C file that includes this header file.

Do not write "int counter;" in a header file. Do write "extern int counter;". Then write "int counter;" in one (1) of your C files.

In the end - when you do create threads on some forum and asks for help you should stop and think for a bit before posting. Don't send until you think you have an affirmative answer to this question: "Have I made sure I have posted all the clues and background information I have available, so that it is meaningful for someone else to even consider my problem?"

Of course, you should also consider this question: "Might I be asking a silly question that I could find the answer to almost instantly if I just bother to try Google?" Remember that pasting error messages from a linker into Google are likely to make you find a number of other people who have seen the exact same error message for the exact same reasons (even if the specific line numbers or symbol names may differ). So you are likely to be able to find specific explanations to messages and also specific explanations on what to change to solve the issues.

The biggest advantage with Google? You can get answers within 5 minutes instead of having to wait until someone interested happens to log on, read your specific question, know the answer and having time/interest to formulate an answer.

Read-Only
Author
Bruce ?
Posted
6-Sep-2012 23:01 GMT
Toolset
C51
New! RE: Did you ever consider trying Google with the search string "keil warning l16"?

Or even looking in the Linker Manual for the description:

http://www.keil.com/support/man/docs/bl51/bl51_l16.htm

Read-Only
Author
Per Westermark
Posted
6-Sep-2012 23:36 GMT
Toolset
C51
New! RE: Did you ever consider trying Google with the search string "keil warning l16"?

Google finds that one too.

Next Thread | Thread List | Previous Thread Start a Thread | Settings

arm-logo-small

Keil logo
Important information

This site uses cookies to store information on your computer. By continuing to use our site, you consent to our cookies.