Community
cancel
Showing results for 
Search instead for 
Did you mean: 
Altera_Forum
Honored Contributor I
1,938 Views

undefined reference to `fopen'

Hi Everyone, 

 

 

I have a probelm with using Nios II Build for Eclipse... I wrote a small C program trying to read from a file, and I get an error 

 

"C:\altera\mysopc_nios_sram\software\mySRAM_image/hello_world_small.c:117: undefined reference to `fopen' 

 

my program is very simple, and I am including all the correct includes 

# include "sys/alt_stdio.h"# include <stdio.h># include <string.h># include <stdlib.h># include "system.h"# include "altera_avalon_pio_regs.h" 

............... 

if( ( InputFile1 = fopen(name_in1, "r") ) == NULL) 

printf("Input File 1 can not be opened \n"); 

 

 

 

please help, 

 

Thank you :)
0 Kudos
7 Replies
Altera_Forum
Honored Contributor I
435 Views

I don't believe you can use "fopen" if you have the "small C library" option selected in the properties for your project.

Altera_Forum
Honored Contributor I
435 Views

Thank you for your reply, but what do I do then?

Altera_Forum
Honored Contributor I
435 Views

I'm not sure what version of Nios you are using but in the past I have opened the system library properties and unchecked "use small C library". This will probably increase your program size so you may need to increase the amount of memory allocated for your program code.

Altera_Forum
Honored Contributor I
435 Views

I am using Nios II 12.0 Software Build Tools for Eclipse, but I don't know where to uncheck "use small C library" ? I looked all over the place, but couldn't find it. Any ideas? 

 

Thanks
Altera_Forum
Honored Contributor I
435 Views

I solved the problem... Here is what I did: 

 

1) I right clicked on my project and choose Nios II --> BSP Editor 

2) on the left hand side options where it says "settings" 

I chose Settings --> Common --> hal --> enable_small_c_library 

3) I unchecked "hal.enable_small_c_library" 

I rebuild the project and it compiled fine :) 

 

 

 

Thank you all for your help....
Altera_Forum
Honored Contributor I
435 Views

Glad you figured it out. 

 

I guess BSP is the new "system library" then.
Altera_Forum
Honored Contributor I
435 Views

Thanks for this info...

Reply