undefined reference to SIGN in C using GCC : <p>Many questions have been asked here about functions from math.h not being found in C code during compilation and I am facing a similar problem. Having gone through all of them, none seems to apply to my problem. I have some C code in a file called test1.c - </p>

<pre><code>#include &lt;math.h&gt;
int main(void) {
  int j = SQR(4);
  int i = (int)(sqrt(16.0));
}
</code></pre>

<p>Now, I compile this using - </p>

<pre><code>gcc -c -o ../../obj/test1.o test1.c -I../../include
</code></pre>

<p>And it produces the .o file. </p>

<p>Now, I try and create the executable using - </p>

<pre><code>gcc -o ../../bin/test1../../obj/test1.o -I../../include -lm
</code></pre>

<p>But this gives me the error below (most previous questions were solved by the -lm switch but I have that) - </p>

<pre><code>../../obj/test1.o:test1.c:(.text+0x13): undefined reference to `SQR'
../../obj/test1.o:test1.c:(.text+0x13): relocation truncated to fit: R_X86_64_PC32 against undefined symbol `SQR'
</code></pre>

<p>Strangely, sqrt works but a host of other functions like SQR, SIGN etc lead to problems (the case doesn't matter). Note that these commands were generated by a make file - </p>

<pre><code>IDIR =../../include
CC=gcc
CFLAGS=-I$(IDIR)

ODIR=../../obj
LDIR =../../lib

LIBS=-lm

_DEPS = nrutil.h
DEPS = $(patsubst %,$(IDIR)/%,$(_DEPS))

_OBJ = test1.o
OBJ = $(patsubst %,$(ODIR)/%,$(_OBJ))


$(ODIR)/%.o: %.c $(DEPS)
  $(CC) -c -o $@ $&lt; $(CFLAGS)

../../bin/svdcmp: $(OBJ)
  gcc -o $@ $^ $(CFLAGS) $(LIBS)

.PHONY: clean

clean:
   rm -f $(ODIR)/*.o *~ core $(INCDIR)/*~
</code></pre>

<p>I'm using Cygwin with Windows.</p>
