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.

Compiler: fastRTS Library compatible with CCS6? -> powf() problem

Other Parts Discussed in Thread: SFRA

Tool/software: TI C/C++ Compiler

Hi,

according to SPRCA75 the C28x Floating Point Unit fastRTS "The library can be used with CCS 3.3 or CCS 4."

I use CCS6.2

I also use rts2800_fpu32.lib.

When using the powf(x,y) function I get following error:

symbol "_sqrt" redefined: first defined in "../../lib/rts2800_fpu32_fast_supplement.lib<sqrt_f32.obj>";
redefined in "..\compiler\c2000_15.12.4.LTS\lib\rts2800_fpu32.lib<e_sqrtf.obj>"

Thank you.

  • Add the following code somewhere in your program.

    #include <math.h>
    #include <float.h>
    
    #if DBL_MANT_DIG == FLT_MANT_DIG
    float cosf(float x) { return cos(x); }
    float sinf(float x) { return sin(x); }
    float sqrtf(float x) { return sqrt(x); }
    #endif

    The reason you are getting this error is because your program uses both sqrt and sqrtf somewhere. It might not be immediately obvious where sqrtf is called; perhaps it is in a library function like printf. Now that the compiler library supports C99, we support not just sqrt, but also sqrtf and sqrtl. For every target TI supports, one of sqrtf or sqrtl is just an alias for sqrt, and is defined in the same file. You've replaced sqrt, but the linker still needs sqrtf, so it must drag in the object file which defines sqrtf, which also contains sqrt, and now you've got duplicate definitions of sqrt. So, when you replace sqrt, you must also replace its alias (in this case sqrtf, because for C2000 COFF, double is 32 bits).

    The rule of thumb: if you replace sqrt, you must also replace sqrtf and sqrtl.

    See also

    https://e2e.ti.com/support/development_tools/compiler/f/343/t/564853

  • Hi,

    sorry but if I do so I get following errors:

    #249 function "__relaxed_cosf" has already been defined
    #249 function "__relaxed_sinf" has already been defined
    #249 function "__relaxed_sqrtf" has already been defined

    I also use:
    SFO_TI_BUILD_V8_FPU.lib
    SFRA_F_Lib.lib

    I don't use sqrt somehow in my code. I can imagine Manish used it in the SFRA lib.


    Thank you for your help.
  • Because you got those error messages, I know you are using the options "--fp_mode=relaxed --tmu_support"

    The underlying problem is still the same (FPUFASTRTS-30), but the workaround is a little stranger:

    #include <float.h>
    
    #if DBL_MANT_DIG == FLT_MANT_DIG
    #if defined(__TMS320C28XX_TMU__) && !__TI_STRICT_FP_MODE__
    __inline float __relaxed_cosf(float x);
    __inline float __relaxed_sinf(float x);
    __inline float __relaxed_sqrtf(float x);
    float cosf(float x) { return __relaxed_cosf(x); }
    float sinf(float x) { return __relaxed_sinf(x); }
    float sqrtf(float x) { return __relaxed_sqrtf(x); }
    #else
    double cos(double);
    double sin(double);
    double sqrt(double);
    float cosf(float x) { return cos(x); }
    float sinf(float x) { return sin(x); }
    float sqrtf(float x) { return sqrt(x); }
    #endif
    #endif
    
    #include <math.h>