This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

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);
}

Parents Reply Children
  • 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

  • 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.