gcc icon indicating copy to clipboard operation
gcc copied to clipboard

float functions not linked with -lm

Open arczi84 opened this issue 1 year ago • 1 comments

Compile:

#include <iostream>
#include <cmath>

int main() {
    // Sample floating-point number
    float number = 3.75;

    // Rounding the number using rintf
    float roundedNumber = rintf(number);

    // Displaying the result
    std::cout << "Number before rounding: " << number << std::endl;
    std::cout << "Rounded number: " << roundedNumber << std::endl;

    return 0;
}

$m68k-amigaos-g++ -Os -m68020 -noixemul rintf.cpp -o rintf -lm Result:

/opt/amiga/lib/gcc/m68k-amigaos/13.1.1/../../../../m68k-amigaos/bin/ld: /tmp/ccpSvFYp.o: in function `main':
/tmp/ccpSvFYp.o:(.text+0x40): undefined reference to `rintf'

Links only with manually providing /opt/amiga/m68k-amigaos/lib/libm020/libm.a

EDIT: Compiled binary is not executable.

arczi84 avatar Nov 11 '23 16:11 arczi84

add -l__m__

bebbo avatar Jan 12 '24 09:01 bebbo