Search code examples
cwindowslinkerturbo-c

linker error undefined symbol _log10f


I am using log10f function of math.h header file and I need to calculate log value in float that's why I use the above function

I am just posting the sample code instead of the actual code due to confidential information

#include<stdio.h>
#include<math.h>
void main(){

    printf(" --->>> %f \n", log10f(4) - log10f(3));
}

Some how I am able to run that code in linux using gcc compiler with following command and it compiled properly and running properly

gcc Demo.c -lm -o Demo

./Demo

But I have to run the project on the windows too and I am using window 7 and turbo c but using tc my program compiled properly but at run time it showing me a LINKER ERROR UNDEFINED SYMBOL _LOG10F

Anyone have any Idea that how can I resolve this issue on Tc at windows. Suggestions are most welcome thanks a lot in advance.


Solution

  • log10f was added to the C language 16 years ago. You are using a a compiler which is 25 years old, so it won't work.

    A work-around might be to use log10 instead, which was available in the C90 standard. It uses double instead of float.