This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

CCS6.1.3 编译fputc时出错,link报错:redfined in "fputc.obj"

用的是Contiki -msp430源码,移植到CC430 CCS环境的代码,

在增加printf 重定向后,报以下错误:

#10056 symbol "fputc" redefined: first defined in "./platform/MSP430/contiki-sky-main.obj"; redefined in "D:\TI\ccsv6\tools
\compiler\msp430_15.12.3.LTS\lib\rts430x_lc_sd_eabi.lib<fputc.obj>" CC430+Contiki_test_1.2.1_ccs C/C++ Problem

添加的代码为:

int
fputc(int ch, register FILE* f)
{
uart0_writeb((uint8_t)ch);
return ch;
}

请帮忙分析一下,找了好久原因 还是一头雾水,就发现编译器会自己去编译stdio下面的一些函数

  • 可以参考一下如下代码

    /*
     * User_debug.c
     *
     *  Created on: Mar 18, 2017
     *      Author: a0222632
     */
    
    #ifndef USER_DEBUG_C_
    #define USER_DEBUG_C_
    
    #include "msp430.h"
    #include <stdio.h>
    #include "User_debug.h"
    
    #ifdef UART_PRINTF
    int fputc(int _c, register FILE *_fp);
    int fputs(const char *_ptr, register FILE *_fp);
    #endif
    
    #ifdef UART_PRINTF
    int fputc(int _c, register FILE *_fp)
    {
      while(!(UCA0IFG&UCTXIFG));
      UCA0TXBUF = (unsigned char) _c;
    
      return((unsigned char)_c);
    }
    
    int fputs(const char *_ptr, register FILE *_fp)
    {
      unsigned int i, len;
    
      len = strlen(_ptr);
    
      for(i=0 ; i<len ; i++)
      {
        while(!(UCA0IFG&UCTXIFG));
        UCA0TXBUF = (unsigned char) _ptr[i];
      }
    
      return len;
    }
    #endif
    
    
    #endif /* USER_DEBUG_C_ */
  • 
    
    
    

    juring 你好:

    我现在是编译的时候,会把msp430_15.12.3.LTS\lib\rts430x_lc_sd_eabi.lib 库里fputc编进去,然后与自己写的fpuc冲突,但是找不到.lib中的fputc被编译进代码的原因???

  • ERIC_Jiang 说:
    
    
    
    

    juring 你好:

    我现在是编译的时候,会把msp430_15.12.3.LTS\lib\rts430x_lc_sd_eabi.lib 库里fputc编进去,然后与自己写的fpuc冲突,但是找不到.lib中的fputc被编译进代码的原因???

    你用的哪颗芯片啊?

    升级一下CCS,现在CCS7不用license了

  • juring 你好:


    我升级了CCS 6.1.3也没解决,索性装了个IAR7.10,把工程放在IAR中编译,就通过了,现在问题解决了,谢谢。