Altera_Forum
Honored Contributor
20 years agohow to set char by uart use fopen and fclose ?
why it give me this message "undefined reference to `fopen'","undefined reference to `fclose'" , when i use fopen and fclose to uart
if i miss any incluse file ? # include "system.h"# include "io.h"# include "stdio.h"# include "altera_avalon_lcd_16207_regs.h"# include "altera_avalon_timer.h"# include "altera_avalon_timer_regs.h"# include "sys/alt_irq.h"# include "altera_avalon_uart_regs.h"# include "altera_avalon_uart.h"# include "alt_types.h"# include "stdlib.h"# include "unistd.h"# include "fcntl.h"# include "sys/alt_alarm.h"# include "string.h"# include "sys/ioctl.h"# include "fcntl.h"# include "string.h"# include "stddef.h"# include "priv/alt_file.h" int main() { FILE *fp ; fp=fopen("/dev/UART_PC_NAME","r+"); //UART_PC_NAME is my uart name if(fp) { fprintf(fp,"close the uart.\n"); fclose(fp); } } this is the error message **** Incremental build of configuration Debug for project otl350a **** make -s all Compiling otl350a.c... ../otl350a.c: In function `main': ../otl350a.c:28: warning: unused variable `u_p' ../otl350a.c:28: warning: unused variable `DATA_R_' ../otl350a.c:30: warning: unused variable `fd0' ../otl350a.c:76:3: warning: no newline at end of file Linking otl350a.elf... obj/otl350a.o(.text+0x28): In function `main': ../otl350a.c:49: undefined reference to `fopen' obj/otl350a.o(.text+0x50):../otl350a.c:52: undefined reference to `fclose' collect2: ld returned 1 exit status make: *** [otl350a.elf] Error 1 Build completed