how to use powf or ceilingf function in rtems..

김찬 ckim at etri.re.kr
Tue Nov 15 07:02:09 UTC 2016


> By the way, I found printf(“PI = %f \n”, 3.1415) prints only “PI = f”. Anybody know in what case this happens?
I was using printk not printf. Sorry.. ☺
Chan Kim

From: 김찬
Sent: Tuesday, November 15, 2016 9:35 AM
To: 'Jinhyun' <jinhyun at konkuk.ac.kr>
Cc: users at rtems.org
Subject: RE: how to use powf or ceilingf function in rtems..

Hello, Jinhyun~
As I said, in my case the –lm option had been given only to the compile command and not the link command.
After I add it to the link command, I can link it. (so it was because of an error in my Makefile).
Hi, all,
By the way, I found printf(“PI = %f \n”, 3.1415) prints only “PI = f”. Anybody know in what case this happens?
In my another program, it prints ok, so it is a build problem..
Thanks!

Chan

From: Jinhyun [mailto:jinhyun at konkuk.ac.kr]
Sent: Monday, November 14, 2016 10:57 AM
To: 김찬 <ckim at etri.re.kr<mailto:ckim at etri.re.kr>>
Cc: users at rtems.org<mailto:users at rtems.org>
Subject: RE: how to use powf or ceilingf function in rtems..

Hi,
I succeed to use powf function in another function without any touch on hello example of rtems-exampls-v2.
I configured RTEMS-4.12 for i386 and use pc386 BSP.

My command for configuration is:
           $ configure --target-i386-rtems4.12 --enable-bsp=pc386 --enable-posix --enable-networking
I use rtems-source-builder for building RTEMS tool sets.
And hello example codes are as below.
/*
*  Classic API Hello World
*/

#include <rtems.h>
#include <stdlib.h>
#include <stdio.h>
#include <math.h>

void another_func(void){
  printf( "powf: %f\n", powf(0.2, 4));
}

rtems_task Init(
  rtems_task_argument ignored
)
{
  printf( "\n\n*** HELLO WORLD TEST ***\n" );
  printf( "Hello World\n" );
  printf( "*** END OF HELLO WORLD TEST ***\n" );
  another_func();
  exit( 0 );
}

/* configuration information */

#include <bsp.h>

/* NOTICE: the clock driver is explicitly disabled */
#define CONFIGURE_APPLICATION_DOES_NOT_NEED_CLOCK_DRIVER
#define CONFIGURE_APPLICATION_NEEDS_CONSOLE_DRIVER
#define CONFIGURE_USE_DEVFS_AS_BASE_FILESYSTEM

#define CONFIGURE_RTEMS_INIT_TASKS_TABLE
#define CONFIGURE_MAXIMUM_TASKS 1

#define CONFIGURE_INIT
#include <rtems/confdefs.h>
/* end of file */

I hope that these will help you.
Jin-Hyun

From: users [mailto:users-bounces at rtems.org] On Behalf Of 김찬
Sent: Sunday, November 13, 2016 10:54 PM
To: joel at rtems.org<mailto:joel at rtems.org>
Cc: rtems-users at rtems.org<mailto:rtems-users at rtems.org> <users at rtems.org<mailto:users at rtems.org>>
Subject: RE: how to use powf or ceilingf function in rtems..

Thanks, Joel,
I added the ‘-lm’ option using XCFLAGS variable (which should be extra compile flags).
So the ‘-lm’ option was given to the compile command (-c) only and was not being given to the link command. So I added –lm option at the end of COBJS list in my Makefile.base (which my Makefile includes).
I tried using XLDCONFIGS but it didn’t’ work I don’t know why.
Thanks!
Chan

From: Joel Sherrill [mailto:joel at rtems.org]
Sent: Saturday, November 12, 2016 11:37 PM
To: 김찬 <ckim at etri.re.kr<mailto:ckim at etri.re.kr>>
Cc: rtems-users at rtems.org<mailto:rtems-users at rtems.org> <users at rtems.org<mailto:users at rtems.org>>
Subject: Re: how to use powf or ceilingf function in rtems..


On Nov 12, 2016 4:44 AM, "김찬" <ckim at etri.re.kr<mailto:ckim at etri.re.kr>> wrote:
>
> Hello,
>
> I’m trying to make an rtems application which uses some math function.
>
> I put #include <math.h>. When the powf function is in the Init() function, it works,
>
> But when powf is called from another function(I want to call this function from Init..), I get ‘undefined reference to powf’ error.
>
> I tried merning the files into one but it is the same. What can be the problem?

You should only have to include math.h and link against libm. There should be nothing odd.

My first guess is that the -lm argument is before the other .o on the link command.

Check that and if that isn't it, can you produce an example?

> Thanks!
>
> Chan Kim
>
>
>
> 김 찬 (Chan Kim)
>
> 책임연구원, 프로세서연구실, 지능형반도체연구부
>
> 한국전자통신연구원
>
> O) 042-860-5773  C) 010-3418-9152  E) ckim at etri.re.kr<mailto:ckim at etri.re.kr>
>
>
>
>
> _______________________________________________
> users mailing list
> users at rtems.org<mailto:users at rtems.org>
> http://lists.rtems.org/mailman/listinfo/users
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.rtems.org/pipermail/users/attachments/20161115/e2d58778/attachment-0001.html>


More information about the users mailing list