undefined reference to “only some math.h” functions

前端 未结 4 645
说谎
说谎 2020-12-06 06:06

I am having a strange problem.

The math libraries has been added to my makefile.

# include standard C library
LDFLAGS += -lc
# include standard math          


        
4条回答
  •  刺人心
    刺人心 (楼主)
    2020-12-06 06:41

    Are you including everywhere?

    Notice that the names in the library are prefixed with __ieee754_, but the ones the linker can't find are not.

    What happens when you compile this code?

    #include 
    
    int main(void)
    {
        double d = pow(2, 3);
        double e = asin(1.0 / d);
        return (int)(e+1);
    }
    

    If the file is mathtest.c, then compile with:

    gcc -o mathtest mathtest.c -lm
    

    (Given that this fails to compile, what symbols are defined in mathtest.o?)


    I added a comment to the main question:

    Which platform are you on? Which C compiler are you using? Are you cross-compiling? What is the command line that is executed to do the linking? (I see DOS/Windows C: paths and PowerPC architecture.) Is there any chance you are using for type-generic math?

    Looking at the LOAD paths you give, I see:

    LOAD c:/gnu/powerpc-eabi/3pp.ronetix.powerpc-eabi/bin/../lib/gcc/powerpc-eabi/4.3.3/../../../../powerpc-eabi/lib/nof\libm.a
    

    Which can, I think, be simplified to:

    LOAD c:/gnu/powerpc-eabi/3pp.ronetix.powerpc-eabi/powerpc-eabi/lib/nof\libm.a
    

    One part of that path that intrigues me is the nof part; could that be 'no floating point'? The other part that really intrigues me is the presence of powerpc with the c: prefix; it smacks of cross-compilation for PowerPC on a Windows platform. It is important to be forthright and explicit about such things; we need that sort of information to be able to help you sensibly.

    Was this the libm.a library that you tested, or did you experiment with another file?

提交回复
热议问题