title: Undefined reference's to c math library on ubuntu
body: <p>I've been trying to run my program after compiling on a Ubuntu 12.04.4 LTS server without any luck. Note I've been developing on my Mac book without any issues.</p>
  
  <p>I've already tried the following number of things:</p>
  
  <ul>
  <li>add -fno-builtin to compile params</li>
  <li>add -lm to compile params (Placing it on several different places before and after *.c files</li>
  <li>added '#define _ISOC99_SOURCE' to source code files</li>
  <li>used --std=gnu99 instead of --std=c99</li>
  <li>add -lt to compile params</li>
  <li>add -Wl,--no-as-needed to compile params</li>
  </ul>
  
  <p>Can any one share with me what I'm doing wrong? Or what missing from my configuration? Below I added the content of my Makefile, output of compiling, the gcc -v output and the output when I try to run the program.</p>
  
  <p>Output of program while trying to run it:</p>
  
  <pre><code>ext/adl-pure.a(adl-main.o): In function `adl_aggregate':
  adl-main.c:(.text+0x1d89): undefined reference to `roundf'
  adl-main.c:(.text+0x2503): undefined reference to `lroundf'
  ext/adl-pure.a(adl-calc.o): In function `adl_get_am_day_target':
  adl-calc.c:(.text+0x2f8): undefined reference to `lroundf'
  ext/adl-pure.a(adl-calc.o): In function `adl_pal_percentage':
  adl-calc.c:(.text+0x787): undefined reference to `floorf'
  adl-calc.c:(.text+0x790): undefined reference to `lroundf'
  collect2: ld returned 1 exit status
  </code></pre>
  
  <p>This is my make file:</p>
  
  <pre><code># Makefile.lib
  
  CC=gcc
  AR=ar
  
  CFLAGS=
  
  .PHONY: all
  .SUFFIXES:
  
  ADL_SOURCES=adl-main.c adl-data.c adl-calc.c adl-fail.c adl-misc.c
  
  all: adl-pure.a
  
  adl-pure.a: $(ADL_SOURCES:.c=.o)
          $(AR) -rus $@ $^
  
  %.o: %.c
          $(CC) -o $@ -MMD $&lt; -lm -std=c99 -O2 -Wall -pedantic $(CFLAGS) -c
  
  clean:
          rm -f adl-pure.a *.o *.d
  
  -include $(ADL_SOURCES:.c=.d)
  </code></pre>
  
  <p>And this the output of it:</p>
  
  <pre><code>gcc -o adl-main.o -MMD adl-main.c -lm -std=c99 -O2 -Wall -pedantic -fPIC -c
  gcc -o adl-data.o -MMD adl-data.c -lm -std=c99 -O2 -Wall -pedantic -fPIC -c
  gcc -o adl-calc.o -MMD adl-calc.c -lm -std=c99 -O2 -Wall -pedantic -fPIC -c
  gcc -o adl-fail.o -MMD adl-fail.c -lm -std=c99 -O2 -Wall -pedantic -fPIC -c
  gcc -o adl-misc.o -MMD adl-misc.c -lm -std=c99 -O2 -Wall -pedantic -fPIC -c
  ar -rus adl-pure.a adl-main.o adl-data.o adl-calc.o adl-fail.o adl-misc.o
  ar: creating adl-pure.a
  </code></pre>
  
  <p>This is the output of gcc -v:</p>
  
  <pre><code>Using built-in specs.
  COLLECT_GCC=gcc
  COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-linux-gnu/4.6/lto-wrapper
  Target: x86_64-linux-gnu
  Configured with: ../src/configure -v --with-pkgversion='Ubuntu/Linaro 4.6.3-1ubuntu5' --with-bugurl=file:///usr/share/doc/gcc-4.6/README.Bugs --enable-languages=c,c++,fortran,objc,obj-c++ --prefix=/usr --program-suffix=-4.6 --enable-shared --enable-linker-build-id --with-system-zlib --libexecdir=/usr/lib --without-included-gettext --enable-threads=posix --with-gxx-include-dir=/usr/include/c++/4.6 --libdir=/usr/lib --enable-nls --with-sysroot=/ --enable-clocale=gnu --enable-libstdcxx-debug --enable-libstdcxx-time=yes --enable-gnu-unique-object --enable-plugin --enable-objc-gc --disable-werror --with-arch-32=i686 --with-tune=generic --enable-checking=release --build=x86_64-linux-gnu --host=x86_64-linux-gnu --target=x86_64-linux-gnu
  Thread model: posix
  gcc version 4.6.3 (Ubuntu/Linaro 4.6.3-1ubuntu5)
  </code></pre>