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.
I've already tried the following number of things:
- add -fno-builtin to compile params
- add -lm to compile params (Placing it on several different places before and after *.c files
- added '#define _ISOC99_SOURCE' to source code files
- used --std=gnu99 instead of --std=c99
- add -lt to compile params
- add -Wl,--no-as-needed to compile params
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.
Output of program while trying to run it:
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
This is my make file:
# 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 $< -lm -std=c99 -O2 -Wall -pedantic $(CFLAGS) -c
clean:
rm -f adl-pure.a *.o *.d
-include $(ADL_SOURCES:.c=.d)
And this the output of it:
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
This is the output of gcc -v:
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)