#1
  1. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Aug 2003
    Posts
    14
    Rep Power
    0

    Undefined reference to


    Hi,

    I am trying to compile some code under linux that was compiled under windows originally.

    I am getting the error "undefined reference to 'MSP430GetTimerTicks"

    The command line code I am running is:

    msp430-gcc -I/import/home/tmp ad9851.c -o ad9851.r43

    In the start of the program I #include the header file of the module that contains MSP430GetTimerTicks but the compiler doesn't seem to be able to find it for some reason.

    I have attached the code for the module that is failing and the include files aswell.

    I'm sure it is a stupid thing I have overlooked but I just can't seem to see what the problem is.

    Any help would be greatly appreciated.

    Matt.

    target.h
    Code:
    #ifndef __TARGET___H_
    #define __TARGET___H_
    
    
    #include "types.h"  
    
    /* Function declarations */
    /**
       * Function to initialize MSP430 microcontroller.
       * This function initializes internal clock sources, timers 
       * starts system timer and disables all interrupts.
       * This function must be called before any other functions 
       * are called
       * 
       * @param     none
       * @return    none
       */
    void MSP430Initialize (void);
    /**
       * Reads current value of system timer ticks
       * 
       * @param     none
       * @return    current system ticks value
       */
    uint32 MSP430GetTimerTicks (void);
    
    #endif /* __TARGET__H_ */
    ad9851.h
    Code:
    #ifndef __AD9851_H_
    #define __AD9851_H_
    
    
    #include "target.h"
    #include "system.h"
    #include "types.h"
    
    /* Default value for AD9851 W0 (refer to AD9851 datasheet for bits description */
    extern const uint8 AD9851_W0;
    
    #define AD8951GSMConfig  0x00000000
    #define AD8951CDMAConfig 0x45E7B272
    
    /**
       * This function programs AD9851 DDS chip
       * 
       * @param     W0      -- W0 programming word (refer AD9851 datasheet for bist description)
       *            divider -- 32-bit clock divider
       * @return    none
       */
    
    void AD9851Set (uint8 W0, uint32 divider);
       
    #endif /* __AD9851_H_ */
    start of ad9851.c
    Code:
    #include <msp430x13x.h>
    #include "ad9851.h"
    
    /* Default value for AD9851 W0 (refer to AD9851 datasheet for bits description */
    const uint8 AD9851_W0 = 0;
    
    /* Default value for AD9851 W0 (refer to AD9851 datasheet for bits description */
    const uint8 AD9851_W0 = 0;
     
    /********************** AD9851Set () ********************************/  
    void AD9851Set (uint8 W0, uint32 divider)
    {
        uint32 time;
        int8 i, n;
        
        /* Now program the chip */
        /* RESET the chip */
        SYN_RESET;
        time = MSP430GetTimerTicks() + TIMEOUT_20_MILLISECOND;
        while(time > MSP430GetTimerTicks())
            ;
    
    :
    :
    Last edited by othermatty; September 21st, 2003 at 09:41 PM.
  2. #2
  3. I'm Baaaaaaack!
    Devshed God 1st Plane (5500 - 5999 posts)

    Join Date
    Jul 2003
    Location
    Maryland
    Posts
    5,538
    Rep Power
    244
    You are not linking with the module that contains the actual binary for MSP430GetTimerTicks() (I assume it is in target.cpp or something like that). Once you find that code, you can direct the linker to it with -L<path to object file>.

    My blog, The Fount of Useless Information http://sol-biotech.com/wordpress/
    Free code: http://sol-biotech.com/code/.
    Secure Programming: http://sol-biotech.com/code/SecProgFAQ.html.
    Performance Programming: http://sol-biotech.com/code/PerformanceProgramming.html.
    LinkedIn Profile: http://www.linkedin.com/in/keithoxenrider

    It is not that old programmers are any smarter or code better, it is just that they have made the same stupid mistake so many times that it is second nature to fix it.
    --Me, I just made it up

    The reasonable man adapts himself to the world; the unreasonable one persists in trying to adapt the world to himself. Therefore, all progress depends on the unreasonable man.
    --George Bernard Shaw
  4. #3
  5. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Aug 2003
    Posts
    14
    Rep Power
    0
    I have created a makefile which includes all the directory. When I run make it shows the first line it is trying to compile and that is when I get the warning. I need so somehow let the compiler know that the code will be coming when everything is compiled. I thought it was something like "extern void MSP430GetTimerTicks (void)" but that doesn't work either. Here is the makefile I am using and the output when I run make.



    Code:
    [othermatty@build src]$ make
    /usr/local/bin/msp430-gcc ad9851.c -o Debug/Obj/ad9851.r43 -g -O2 -I.
    /usr/local/lib/gcc-lib/msp430/3.2.3/libgcc.a(_reset_vector__.o)(.init+0x38): In
    function `_reset_vector__':
    : undefined reference to `main'
    /tmp/cc0XP7lz.o(.text+0x1a): In function `AD9851Set':
    /import/linux/home/othermatty/rudolfcvs/firmware/rfctrl/src/ad9851.c
    :43: undefined reference to `MSP430GetTimerTicks'
    /tmp/cc0XP7lz.o(.text+0x26):/import/linux/home/othermatty/rudolfcvs/
    firmware/rfctrl/src/ad9851.c:44: undefined reference to `MSP430GetTimerTicks'
    /tmp/cc0XP7lz.o(.text+0x9e):/import/linux/home/othermatty/rudolfcvs/
    firmware/rfctrl/src/ad9851.c:98: undefined reference to `sDefaultSettings'
    /tmp/cc0XP7lz.o(.text+0xa4):/import/linux/home/othermatty/rudolfcvs/
    firmware/rfctrl/src/ad9851.c:98: undefined reference to `sDefaultSettings'
    make: *** [Debug/Obj/ad9851.r43] Error 1
    [othermatty@build src]$
    makefile:

    Code:
    SHELL = /bin/sh
    .SUFFIXES:
    .SUFFIXES: .c .o .r43 .d43
    
    #########################################################################
    
    TOOLS_PATH = /usr/local/bin
    OBJ_PATH = ./Debug/Obj
    EXE_PATH = ./Debug/Exe
    MAP_PATH = ./Debug/List
    INC_PATH = .
    LIB_INC_PATH = /usr/local/lib
    
    
    #########################################################################
    #
    # Include the make variables (CC, etc...)
    #
    AS	= $(TOOLS_PATH)/msp430-as
    LD	= $(TOOLS_PATH)/msp430-ld
    CC	= $(TOOLS_PATH)/msp430-gcc
    
    DBGFLAGS= -gstabs+ -DDEBUG
    OPTFLAGS= -Os -fomit-frame-pointer
    
    
    MAP_FILE = 	$(MAP_PATH)/rfcontrol.map
    LINK_FILE = 	rfcontrol.xcl
    
    CFLAGS_DEBUG := -r
    CFLAGS :=-g -O2 -I$(INC_PATH)
    AFLAGS := -a -D__ASSEMBLY__ $(CPPFLAGS) 
    LDFLAGS := -mmcu=msp430x13 -L$(LIB_INC_PATH)
    
    OBJS  = $(OBJ_PATH)/ad9851.r43 \
    	$(OBJ_PATH)/flash.r43 \
    	$(OBJ_PATH)/gainctrl.r43 \
    	$(OBJ_PATH)/lmx2306.r43  \
    	$(OBJ_PATH)/main.r43 \
    	$(OBJ_PATH)/protocol.r43  \
    	$(OBJ_PATH)/serial.r43  \
    	$(OBJ_PATH)/target.r43 
    
    TARGET = $(EXE_PATH)/rfcontrol.d43
    
    #########################################################################
    
    
    all:		$(TARGET) 
    
    
    $(OBJ_PATH)/%.r43 : %.c
    	$(CC) $< -o $@ $(CFLAGS) 
    
    $(TARGET):	$(OBJS) 
    		$(LD) $(OBJS) $(LDFLAGS) -o $@  
    
    #########################################################################
    
    clean:
    
    clobber:	clean
    	rm -f $(OBJS) *.bak 
    	rm -f $(TARGET)
    	rm -f $(MAP_FILE)
    
    #########################################################################
  6. #4
  7. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Aug 2003
    Posts
    14
    Rep Power
    0
    Sorry, I'm with you now. The problem was my makefile. All fixed now.

    Thanks for all you help.

    Matt.
    Last edited by othermatty; September 23rd, 2003 at 04:47 PM.

IMN logo majestic logo threadwatch logo seochat tools logo