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.
12409 Discussions

DS-5 Baremetal Linker Error: Undefined Reference

Altera_Forum
Honored Contributor II
1,328 Views

Hi, 

 

I have built a small baremetal application to test the system built in Qsys. I'm using some predefined functions like alt_cache_system_disable and alt_bridge_init.  

The header files for these functions are included and paths for the same are added into the projects includes(Properties->C/C++ general->Paths and symbols) from the altera IP libraries. The files generated for the system is also included. 

The linker throws an error saying undefined reference to these functions. The log is shown below: 

 

make all  

'Building file: ../test.c' 

'Invoking: GCC C Compiler' 

arm-altera-eabi-gcc -ID:/Altera/embedded/ip/altera/hps/altera_hps/hwlib/include -ID:/Altera/projects/system/hps_isw_handoff/system_HPS_system -I"D:\Altera\embedded\ip\altera\hps\altera_hps\hwlib\src" -O2 -g -Wall -std=c99 -MMD -MP -MF"test.d" -MT"test.d" -c -o "test.o" "../test.c" 

../test.c: In function 'main': 

../test.c:58:3: warning: implicit declaration of function 'alt_log_printf' [-Wimplicit-function-declaration] 

alt_log_printf("Bridge Init Success\n"); 

'Finished building: ../test.c' 

' ' 

'Building target: test.axf' 

'Invoking: GCC C Linker' 

arm-altera-eabi-gcc -o "test.axf" ./test.o  

d:/altera/embedded/host_tools/mentor/gnu/arm/baremetal/bin/../lib/gcc/arm-altera-eabi/4.9.1/../../../../arm-altera-eabi/bin/ld.exe: warning: cannot find entry symbol _start; defaulting to 00008018 

./test.o: In function `main': 

C:\Users\Administrator\Documents\DS-5 Workspace\test\Debug/../test.c:55: undefined reference to `alt_bridge_init' 

C:\Users\Administrator\Documents\DS-5 Workspace\test\Debug/../test.c:62: undefined reference to `alt_log_printf' 

C:\Users\Administrator\Documents\DS-5 Workspace\test\Debug/../test.c:67: undefined reference to `alt_cache_system_disable' 

collect2.exe: error: ld returned 1 exit status 

make: *** [test.axf] Error 1 

 

When I looked around, this seems to be a common issue. One of the solution was to include the flag -specs=nosys.spec. When this flag was added, the linker could not find this flag. 

 

Any help with this issue is much appreciated. Thanks in advance. 

 

Best Regards, 

Nitin.
0 Kudos
2 Replies
Altera_Forum
Honored Contributor II
339 Views

This error was solved. Unlike normal eclipse, DS-5 requires all the source files of the includes to be added into the project. The target properties under the GCC C compiler has to be set for the respective CPU, architec  

 

Additionally the flag -std=c99 can be included to avoid errors certain C constructs used in a few pre-defined files.
Altera_Forum
Honored Contributor II
339 Views

Before this where did you placed the source files.? so adding the flasg solving everything? cool !

Reply