. Advertisement .
..3..
. Advertisement .
..4..
I’m building a new program, but when I run it, an error pops up. The error displayed is as follows:
main.c:(.text+0x33): undefined reference to `clrscr'
collect2: error: ld returned 1 exit status
I have tried several workarounds, but they still do not get the desired results. If you have come across this situation and have a solution for the collect2.exe: error: ld returned 1 exit status problem, pls let me know. This is what I do:
void main() {
char chr;
printf("ENTER a character");
scanf("%c",&chr);
clrscr();
switch(chr) {
default:
printf("\nHello..\n");
break;
case 1:
printf("\nHi one");
break;
case 2:
printf("\nHi two\n");
break;
}
}
Thanks.
The cause: The clrscr() is not standard C function
Solution: Use system (“cls”) without using clrscr () . To use it, add #include<stdlib.h>
You have a reference to the missing symbols in your case. In some cases, however, ld may not give error information.
To expand the information provided in ld, simply add the following parameters into your $(LDFLAGS).