Nios® V/II Embedded Design Suite (EDS)
Support for Embedded Development Tools, Processors (SoCs and Nios® V/II processor), Embedded Development Suites (EDSs), Boot and Configuration, Operating Systems, C and C++
12589 Discussions

undefined reference to `fopen'

Altera_Forum
Honored Contributor II
4,000 Views

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 II
2,497 Views

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

0 Kudos
Altera_Forum
Honored Contributor II
2,497 Views

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

0 Kudos
Altera_Forum
Honored Contributor II
2,497 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.

0 Kudos
Altera_Forum
Honored Contributor II
2,497 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
0 Kudos
Altera_Forum
Honored Contributor II
2,497 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....
0 Kudos
Altera_Forum
Honored Contributor II
2,497 Views

Glad you figured it out. 

 

I guess BSP is the new "system library" then.
0 Kudos
Altera_Forum
Honored Contributor II
2,497 Views

Thanks for this info...

0 Kudos
Reply