Nios® II Embedded Design Suite (EDS)
Support for Embedded Development Tools, Processors (SoCs and Nios® II processor), Embedded Development Suites (EDSs), Boot and Configuration, Operating Systems, C and C++
Announcements
Intel Support hours are Monday-Fridays, 8am-5pm PST, except Holidays. Thanks to our community members who provide support during our down time or before we get to your questions. We appreciate you!

Need Forum Guidance? Click here
Search our FPGA Knowledge Articles here.
12408 Discussions

undefined reference to `fopen'

Altera_Forum
Honored Contributor II
2,544 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
1,041 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 II
1,041 Views

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

Altera_Forum
Honored Contributor II
1,041 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 II
1,041 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 II
1,041 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 II
1,041 Views

Glad you figured it out. 

 

I guess BSP is the new "system library" then.
Altera_Forum
Honored Contributor II
1,041 Views

Thanks for this info...

Reply