Question

I am trying to implement the C function "exp" in NASM for Linux. The function takes a double value x, and returns a double value r = e^x, where e is Euler's Number. This is my implementation:

extern exp

SECTION .bss

    doubleActual: resq 1
    doubleX: resq 1

SECTION .text

    main:
    ;some other code here

    ;calculate actual result
    push doubleActual ; place to store result
    push doubleX ;give the function what x is.
    call exp
    add esp, 8

On compile attempt, i get the following:

hw7_3.o: In function `termIsLess':
hw7_3.asm:(.text+0xf9): undefined reference to `exp'

This is referring to when i actually call exp, which is odd, because "extern exp" seems to work just fine. What am i doing incorrectly?

Was it helpful?

Solution

via http://www.linuxtopia.org/online_books/an_introduction_to_gcc/gccintro_17.html ....

I need to do the following with gcc:

gcc -m32 name.o -lm -o name

The "-lm" tag is a shortcut to link the C math library, which is separate from the standard library.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top