Undefined reference to `__fabs

キャンセル
次の結果を表示 
表示  限定  | 次の代わりに検索 
もしかして: 

Undefined reference to `__fabs

ソリューションへジャンプ
4,979件の閲覧回数
jiajian_qiu
Contributor II

Hi:

    My project has below error info when use fabs() function:

   S32DS/e200_ewl2/EWL_C/src/math/fabsf.c undefined reference to `__fabs' Demo line 22 C/C++ Problem

   Platform : S32 Design Studio for Power Architecture Version: 2017.R1   MPC5748G

   The fabsf.c:

      #include <ansi_parms.h>

      #include <ewl_misra_types.h>

      #if _EWL_FLOATING_POINT && _EWL_USES_SUN_SP_MATH_LIB

      #include <math.h>

      #ifdef __USING_INTRINSIC_FABS__

      #define __HAS_FABS 1

      extern double fabs(double x)
      {
      return __fabs(x) ;
      }

   So I need to include some head files? 

   I look forward to receiving a response., thanks !

ラベル(2)
タグ(2)
1 解決策
4,339件の閲覧回数
b48014
NXP Employee
NXP Employee

Hi,

Do you want to use only EWL library? You can use newlib library instead:

1. Delete #define fabs(x) implementation from your Main_Z4b.c file

2. Add libm library in linker settings and delete "${VLE_EWL_DIR}\lib\e200z4\fp" from Library search path

pastedImage_37.png

3. Select newlib in Target Processor settings

pastedImage_36.png

I hope it will help. :smileyhappy:

PS: If you still want to use EWL:

1. Delete Release and Debug folders from your project.

2. Delete #define fabs(x) implementation from your Main_Z4b.c file.

3. Uncheck the following settings:

pastedImage_4.png

4. You are welcome.

Best regards,

Dmitry

元の投稿で解決策を見る

7 返答(返信)
4,339件の閲覧回数
jiri_kral
NXP Employee
NXP Employee

Hi, 

i tried hello world project - and only what I need to add is #include <math.h>

pastedImage_2.png

Also make sure that hardware floating point is enabled in project properties:

pastedImage_1.png

0 件の賞賛
4,339件の閲覧回数
jiajian_qiu
Contributor II

Hi Jiri:

   Thanks for your reply.

   I find 'fabs()' can be work in new project, but my project is new by older version S32DS.

   Some head file not similar to new project. The attachment is my demo project.  

   I would appreciate it if you could use my project (file Main_Z4b.c line 21).

   PS: I can't rebuild a new project on the new version.

   Best regards.

0 件の賞賛
4,340件の閲覧回数
b48014
NXP Employee
NXP Employee

Hi,

Do you want to use only EWL library? You can use newlib library instead:

1. Delete #define fabs(x) implementation from your Main_Z4b.c file

2. Add libm library in linker settings and delete "${VLE_EWL_DIR}\lib\e200z4\fp" from Library search path

pastedImage_37.png

3. Select newlib in Target Processor settings

pastedImage_36.png

I hope it will help. :smileyhappy:

PS: If you still want to use EWL:

1. Delete Release and Debug folders from your project.

2. Delete #define fabs(x) implementation from your Main_Z4b.c file.

3. Uncheck the following settings:

pastedImage_4.png

4. You are welcome.

Best regards,

Dmitry

1,519件の閲覧回数
PCS13
Contributor I

hello, I am having the same problem for S32K148 on S32DS.

How to solve this ld error:undefned reference to 'ciel'?

Which library to add and what Target processor settings to do? 

0 件の賞賛
4,339件の閲覧回数
jiajian_qiu
Contributor II

Hi Dmitry:

   I use new library and 'fabs()' work now ^_^.

   Thanks very much.

Best regards.

0 件の賞賛
4,339件の閲覧回数
vinothkumars
Senior Contributor IV

Include this content in your fabsf.c file and build

#define __fabs \ ({ \     double __value, __arg = (x); \     asm volatile ("fabs %0,%1" : "=f" (__value): "f" (__arg)); \     __value; \ })  

Regards,

VinothS

Regards,
Vinothkumar Sekar
0 件の賞賛
4,339件の閲覧回数
jiajian_qiu
Contributor II

Hi VinothS:

   Thanks for your reply.

   I have do as you say and change some base platform.

    #define fabs(x) \

   ({ \
   double __value, __arg = (x); \
   __asm__ volatile ("fabs %0,%1" : "=f" (__value): "f" (__arg)); \
    __value; \
   })

   But the compiler report another error.
   impossible constraint in 'asm' 

   

   Upload a demo project , it's delete part of the code.

   I would appreciate it if you could use my project (file Main_Z4b.c line 21).

 

   Best regards.

0 件の賞賛