MSP430 math.h build error

ChibiOS public support forum for all topics not covered by a specific support forum.

Moderators: RoccoMarco, lbednarz, tfAteba

Post Reply
rpcaldeira
Posts: 9
Joined: Sat Jun 14, 2014 5:01 pm

MSP430 math.h build error

Post by rpcaldeira »

Hello guys!

I'm having a problem where i'm trying to use the math library in my code but it doesen't work.

Code: Select all

#include <stdio.h>
#include <string.h>
#include <inttypes.h>
#include <stdint.h>
#include <stdlib.h>
#include <math.h>


it is included and present in the makefile:

Code: Select all

##############################################################################
# Start of default section
#

# List all default C defines here, like -D_DEBUG=1
DDEFS = -D__MSP430F1611__

# List all default ASM defines here, like -D_DEBUG=1
DADEFS =

# List all default directories to look for include files here
DINCDIR =

# List the default directory to look for the libraries here
DLIBDIR = /usr/msp430/lib

# List all default libraries here
DLIBS = -lm


can anyone help me? Thanks guys
User avatar
Giovanni
Site Admin
Posts: 14892
Joined: Wed May 27, 2009 8:48 am
Has thanked: 1202 times
Been thanked: 996 times

Re: MSP430 math.h build error

Post by Giovanni »

You should detail the "does not work" part.

Giovanni
rpcaldeira
Posts: 9
Joined: Sat Jun 14, 2014 5:01 pm

Re: MSP430 math.h build error

Post by rpcaldeira »

I'm deeply sorry, must have been the rush :/

When comes to the linking part, it gives me the undefined reference error

Code: Select all

msp430-gcc ../../os/ports/GCC/MSP430/chcoreasm.o ../../os/kernel/src/chsys.o ../../os/kernel/src/chdebug.o ../../os/kernel/src/chlists.o ../../os/kernel/src/chvt.o ../../os/kernel/src/chschd.o ../../os/kernel/src/chthreads.o ../../os/kernel/src/chdynamic.o ../../os/kernel/src/chregistry.o ../../os/kernel/src/chsem.o ../../os/kernel/src/chmtx.o ../../os/kernel/src/chcond.o ../../os/kernel/src/chevents.o ../../os/kernel/src/chmsg.o ../../os/kernel/src/chmboxes.o ../../os/kernel/src/chqueues.o ../../os/kernel/src/chmemcore.o ../../os/kernel/src/chheap.o ../../os/kernel/src/chmempools.o ../../test/test.o ../../test/testthd.o ../../test/testsem.o ../../test/testmtx.o ../../test/testmsg.o ../../test/testmbox.o ../../test/testevt.o ../../test/testheap.o ../../test/testpools.o ../../test/testdyn.o ../../test/testqueues.o ../../test/testbmk.o ../../os/hal/src/hal.o ../../os/hal/src/adc.o ../../os/hal/src/can.o ../../os/hal/src/ext.o ../../os/hal/src/gpt.o ../../os/hal/src/i2c.o ../../os/hal/src/icu.o ../../os/hal/src/mac.o ../../os/hal/src/mmc_spi.o ../../os/hal/src/mmcsd.o ../../os/hal/src/pal.o ../../os/hal/src/pwm.o ../../os/hal/src/rtc.o ../../os/hal/src/sdc.o ../../os/hal/src/serial.o ../../os/hal/src/serial_usb.o ../../os/hal/src/spi.o ../../os/hal/src/tm.o ../../os/hal/src/uart.o ../../os/hal/src/usb.o ../../os/hal/platforms/MSP430/hal_lld.o ../../os/hal/platforms/MSP430/pal_lld.o ../../os/hal/platforms/MSP430/serial_lld.o ../../boards/TRENZ_0600_02/board.o ../../os/various/memstreams.o ../../os/various/chprintf.o ../../os/various/shell.o ../../os/various/evtimer.o RF/driver/RF.o RF/basicrf/basic_rf.o main.o  -mmcu=msp430x1611 -Tmsp430.x -Wl,-Map=Thesis.map,--cref,--no-warn-mismatch -L/usr/msp430/lib -lm  -o Thesis.elf
RF/basicrf/basic_rf.o: In function `randn':
basic_rf.c:(.text+0x5cc): undefined reference to `exp'
RF/basicrf/basic_rf.o: In function `expon':
basic_rf.c:(.text+0x6e4): undefined reference to `log'
collect2: ld returned 1 exit status


thanks again :)
User avatar
Giovanni
Site Admin
Posts: 14892
Joined: Wed May 27, 2009 8:48 am
Has thanked: 1202 times
Been thanked: 996 times

Re: MSP430 math.h build error

Post by Giovanni »

Hi,

It looks related to the compiler, did you build it yourself? check if in the library there are those symbols because apparently not.

Giovanni
rpcaldeira
Posts: 9
Joined: Sat Jun 14, 2014 5:01 pm

Re: MSP430 math.h build error

Post by rpcaldeira »

Hey, no it was not built by me. Those are the packages msp430-libc, msp430mcu, mspdebug from XUbuntu 14.04.

That was my frist thought too but when i looked at the math.h file...

Code: Select all

#ifndef _REENT_ONLY
#ifndef __math_6881
extern double acos _PARAMS((double));
extern double asin _PARAMS((double));
extern double atan2 _PARAMS((double, double));
extern double cosh _PARAMS((double));
extern double sinh _PARAMS((double));
extern double exp _PARAMS((double));
extern double ldexp _PARAMS((double, int));
extern double log _PARAMS((double));
extern double log10 _PARAMS((double));
extern double logb _PARAMS((double));
extern double pow _PARAMS((double, double));
extern double sqrt _PARAMS((double));
extern double fmod _PARAMS((double, double));
#endif /* ! defined (__math_68881) */
#endif /* ! defined (_REENT_ONLY) */


The functions are defined, so they should be implemented :S

Thanks again,
Rui
User avatar
Giovanni
Site Admin
Posts: 14892
Joined: Wed May 27, 2009 8:48 am
Has thanked: 1202 times
Been thanked: 996 times

Re: MSP430 math.h build error

Post by Giovanni »

The functions are defined in the header, you should verify if the library really contains them.

Giovanni
rpcaldeira
Posts: 9
Joined: Sat Jun 14, 2014 5:01 pm

Re: MSP430 math.h build error

Post by rpcaldeira »

You were right i used

Code: Select all

nm ./libm.a | grep -w T | grep -E 'log|exp'
and they were not there.

Thanks a million,
Rui :)
Post Reply