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++

A bug in libm.a?

Altera_Forum
Honored Contributor II
1,574 Views

All, 

 

Today, when I build my application without any debugging information, everything is OK. But when I am going to link the .gdb file for debugging, the problem shows up. I got an "undefined error" when linking the .bin file into .gdb file. After checking the problem, I found in the Rules.mak file, it still uses the lib provided by newlib not uclibc, while we are using the libc.a from uclibc. 

 

After changing the LIBM to libm.a provided from uclibc, the problem is solved. 

 

Is it a bug? 

 

<div class='quotetop'>QUOTE </div> 

--- Quote Start ---  

######################################################## #   I use the libm.a provided by uclibc instead of#   newlib.# # ###################################################### 

LIBM        := $(LIBCDIR)/lib/libm.a# LIBM  := $(shell $(CC) -print-file-name=libm.a)[/b] 

--- Quote End ---  

0 Kudos
3 Replies
Altera_Forum
Honored Contributor II
542 Views

Hi, 

 

We used the newlib&#39;s libm because we found it to be more efficient. What was the specific error message that you got?
0 Kudos
Altera_Forum
Honored Contributor II
542 Views

Hi, Randy, 

 

The following is the error information I got. Thanks. 

 

<div class='quotetop'>QUOTE </div> 

--- Quote Start ---  

nios2-elf-ld -T C:/altera/kits/nios2/bin/eclipse/plugins/com.microtronix.nios2linux.application_0.1.0/scripts/elf2flt.ld -o kvm_g.gdb kvm_g.bin 

kvm_g.bin(.text+0x3b298): In function `fmod&#39;: 

/build/nios2/bin/nios2-gnutools/src/newlib/newlib/libm/math/w_fmod.c:97: undefined reference to `__errno&#39; 

kvm_g.bin(.text+0x3b2c8):/build/nios2/bin/nios2-gnutools/src/newlib/newlib/libm/math/w_fmod.c:100: undefined reference to `__errno&#39; 

make[1]: *** [kvm_g.gdb] Error 1[/b] 

--- Quote End ---  

0 Kudos
Altera_Forum
Honored Contributor II
542 Views

Hi neo,  

 

Yes. It is a problem. You are right to use the libm from uClibc. The libm from newlib is compiled with newlib header files, and should not be used together with uClibc. Thanks for your finding, 

 

wentao
0 Kudos
Reply