Jump to content
OMRON Forums

Release build fails on Math function


daves
 Share

Recommended Posts

IDE 2.0.2.16 FW 2.0.0.1

 

Why does the Debug configuration build and run OK but the Release configuration does not? How can I make it work:

 

Any C code but try in capp1 for easy demonstration:

 

#include 
#include "../../Include/pp_proj.h"

int main(void) 
{
int a ;

InitLibrary();

a = rint(1.5);

CloseLibrary();	
return 0;
}

 

PS The error code/message is hidden in the err.log file rather than in the IDE. We see this a lot and would appreciate the error being surfaced...

Link to comment
Share on other sites

  • 3 weeks later...
  • Replies 12
  • Created
  • Last Reply

Top Posters In This Topic

Top Posters In This Topic

Posted Images

Try using the latest patch for the IDE - this should be corrected.

 

No. The exact same problem is happening. How was it corrected?

 

Is there some guide to using math functions? I am confused as to how math.h and rtpmaclib.h are utilised by PPMAC/RT...

 

Thanks

Dave

Link to comment
Share on other sites

Try using the latest patch for the IDE - this should be corrected.

 

No. The exact same problem is happening. How was it corrected?

 

Is there some guide to using math functions? I am confused as to how math.h and rtpmaclib.h are utilised by PPMAC/RT...

 

Thanks

Dave

 

The header file "math.h" is part of the C compiler. Usage of these functions is describe in any good C text.

 

The file "rtpmaclib.h" is part of the PPMAC language. These are described in the "Help" feature of the IDE under "Contents":

193421464_idehelpcontent.JPG.1e674176d6c11d2e0ae6044c25fe31b6.JPG

Link to comment
Share on other sites

The header file "math.h" is part of the C compiler. Usage of these functions is describe in any good C text.

I understand this. Are we not allowed to use standard maths functions / some or all of the standard C include files? The following standard math.h functions do not compile:

capp1.c(39,0): Warning :  incompatible implicit declaration of built-in function 'exp10'
capp1.c(40,0): Warning :  incompatible implicit declaration of built-in function 'pow10'
capp1.c(83,0): Warning :  incompatible implicit declaration of built-in function 'tgamma'
capp1.c(89,0): Warning :  incompatible implicit declaration of built-in function 'nexttoward'
capp1.c(93,0): Warning :  incompatible implicit declaration of built-in function 'scalbln'
capp1.c(94,0): Warning :  incompatible implicit declaration of built-in function 'nearbyint'
capp1.c(95,0): Warning :  incompatible implicit declaration of built-in function 'round'
capp1.c(96,0): Warning :  incompatible implicit declaration of built-in function 'trunc'
capp1.c(97,0): Warning :  incompatible implicit declaration of built-in function 'remquo'
capp1.c(98,0): Warning :  incompatible implicit declaration of built-in function 'lrint'
capp1.c(99,0): Warning :  incompatible implicit declaration of built-in function 'llrint'
capp1.c(100,0): Warning :  incompatible implicit declaration of built-in function 'lround'
capp1.c(101,0): Warning :  incompatible implicit declaration of built-in function 'llround'
capp1.c(102,0): Warning :  incompatible implicit declaration of built-in function 'fdim'
capp1.c(103,0): Warning :  incompatible implicit declaration of built-in function 'fmax'
capp1.c(104,0): Warning :  incompatible implicit declaration of built-in function 'fmin'
capp1.c(105,0): Warning :  incompatible implicit declaration of built-in function 'fma'
rinttest.ppproj(112,5): Error : capp1.o: In function `main':
capp1capp1.c(39,0): Error :  undefined reference to `exp10' 
capp1capp1.c(40,0): Error :  undefined reference to `pow10' 
capp1capp1.c(42,0): Error :  undefined reference to `expm1' 
capp1capp1.c(44,0): Error :  undefined reference to `logb' 
capp1capp1.c(49,0): Error :  undefined reference to `hypot' 
capp1capp1.c(57,0): Error :  undefined reference to `isfinite' 
capp1capp1.c(59,0): Error :  undefined reference to `drem' 
capp1capp1.c(63,0): Error :  undefined reference to `nan' 
capp1capp1.c(81,0): Error :  undefined reference to `erfc' 
capp1capp1.c(83,0): Error :  undefined reference to `tgamma' 
capp1capp1.c(85,0): Error :  undefined reference to `gamma' 
capp1capp1.c(88,0): Error :  undefined reference to `nextafter' 
capp1capp1.c(89,0): Error :  undefined reference to `nexttoward' 
capp1capp1.c(90,0): Error :  undefined reference to `remainder' 
capp1capp1.c(92,0): Error :  undefined reference to `ilogb' 
capp1capp1.c(93,0): Error :  undefined reference to `scalbln' 
capp1capp1.c(94,0): Error :  undefined reference to `nearbyint' 
capp1capp1.c(97,0): Error :  undefined reference to `remquo' 
capp1capp1.c(98,0): Error :  undefined reference to `lrint' 
capp1capp1.c(99,0): Error :  undefined reference to `llrint' 
capp1capp1.c(102,0): Error :  undefined reference to `fdim' 
capp1capp1.c(103,0): Error :  undefined reference to `fmax' 
capp1capp1.c(104,0): Error :  undefined reference to `fmin' 
capp1capp1.c(105,0): Error :  undefined reference to `fma' 
Error : collect2: ld returned 1 exit status

Some due to warnings, some due to errors. The results are different in a Release build.

 

The file "rtpmaclib.h" is part of the PPMAC language. These are described in the "Help" feature of the IDE under "Contents":

Is the conclusion you can only use C functions from these libraries safely (pot luck if other C functions work)?

The details in the help files are scant/missing. See the following, for example:

bfprotwrite bfwrite dtostr gray_to_bin index* itoHEXstr itostr log mem_set memcopy move_mem MoveProgData my* protwrite randx rnd rtsqrt seed
str* test_bits* utostr

 

I think my original rint() problem is a genuine one. I have already come across the fabs() issue in kernel mode compilation post.

 

We are embarking on some more complicated mathematical routines and would like some more guidance on what the Delta Tau flavour of C we are working with here is.

Link to comment
Share on other sites

You can use any of the standard C functions but you must include the needed header files. If you include any of the PPMAC library header files you can use any of its functions. The IDE links at compile time to our libs and the Linux libs but will use the PPMAC function of the same name. It is usually best to use only the PPMAC functions - after all this is what the product is designed as. I will have the programmers look at some of the "clashing" function declarations you have shown.

 

Let me know what PPMAC library functions are not well defined – I can have the programmers provide better descriptions.

Link to comment
Share on other sites

Thanks for looking at this.

 

To get the list I posted above, I just quickly clicked through the items in the help file and noted down the ones which had no information. If they do this they should see too.

 

I understand doc often ends up being the last thing done and then more 'pressing' tech requirements come along. I am guilty of doing this myself, however I would suggest a dev library or API really needs a bit of detail documenting the features the customer will be delving into.

 

Any expansion on an auto-gathered copy of the function prototypes would be helpful. Example code / scope of validity (user/kernel)/ words of warning etc all go a long way to make coding a more joyful experience!

Link to comment
Share on other sites

your rint() problem is genuine one. When you compile your code in Release mode, we try to optimize your executable. The compiler replaces your original rint() function to a more optimized lrintf() function, depending on the parameter of the function and it's return type. We have our own math library in the Power PMAC and we are not using the standard math library because it is not as efficient as we want it to be. In our math library we have rint() function defined but we do not have lrintf() and that is why you see the error. We have two ways of solving your problem. One way is to use custom make files in the IDE and lower the optimization to stop the compiler from optimizing rint() function. I will explain you more about this route if you decide to use it. The other solution is to declare the lrintf() function in your capp1.c file as the following.

 

double lrintf(double x)

{

return rint(x);

}

 

and change your call to:

 

a=(int)rint(1.5);

Link to comment
Share on other sites

Hi,

 

your rint() problem is genuine one. When you compile your code in Release mode, we try to optimize your executable. The compiler replaces your original rint() function to a more optimized lrintf() function, depending on the parameter of the function and it's return type.

 

Trig functions like sin() also have this behaviour under optimization, FWIW. I also discovered the "define it yourself" workaround.

 

The biggest issue for me is that the build & download process does not report this and the only indication you have is that something fails at runtime and you're left guessing. See http://forums.deltatau.com/bugzilla/show_bug.cgi?id=1082

Link to comment
Share on other sites

I am working on fixing this bug so it will display errors that fall in that special category. rint was a special case, but I have not seen any errors in using the sin() function. how are you using it?
Link to comment
Share on other sites

  • 2 weeks later...

double lrintf(double x)

{

return rint(x);

}

 

a=(int)rint(1.5);

 

Thanks for looking at this, I have just found the time to try it. I now get a warning (Debug or Release):

 

Warning :  conflicting types for built-in function 'lrintf'

 

Debug gives a = 2;

Release gives a = 0;

 

So this does not work!

 

Also my real problem is in RTICPLC and this still does not build with your lrint solution.

 

Please help! I need to be able to use math functions in all situations...

 

Thanks

dave

Link to comment
Share on other sites

  • 5 months later...
Guest
This topic is now closed to further replies.
 Share


×
×
  • Create New...