Unable to find reference to std library math function inside library
Posted
by Alex Marshall
on Stack Overflow
See other posts from Stack Overflow
or by Alex Marshall
Published on 2010-03-18T17:12:59Z
Indexed on
2010/03/18
17:41 UTC
Read the original article
Hit count: 334
Hello,
I've got several programs that use shared libraries. Those shared libraries in turn use various standard C libraries. ie
Program A and Program B both use Shared Library S. Shared Library S uses std C math. I want to be able to statically link Shared Library S against the standard library, and then statically link Programs A and B against S so that I don't have to be dragging around the library files, because these programs are going to be running on an embedded system running BusyBox 0.61. However, when I try to statically link the programs against Shared Library S, I get an error message from GCC stating :
../lib/libgainscalecalc.a(gainscalecalc.): In function 'float2gs':
[path to my C file].c:73: undefined reference to 'log'
Can somebody please help me out ? The make commands I'm using are below :
CFLAGS += -Wall -g -W
INCFLAGS = -I$(CROSS_INCLUDE)/usr/include
LIBFLAGS += -L$(CROSS_LIB)/usr/lib -lm
gainscalecalc_static.o: gainscalecalc.c
$(CC) $(CFLAGS) -c $< -I. $(INCFLAGS) -o $@
gainscalecalc_dynamic.o: gainscalecalc.c
$(CC) $(CFLAGS) -fPIC -c $< -o $@
all: staticlib dynamiclib static_driver dynamic_driver
clean:
$(RM) *.o *.a *.so *~ driver core $(OBJDIR)
static_driver: driver.c staticlib
$(CC) $(CFLAGS) -static driver.c $(INCFLAGS) $(LIBFLAGS) -I. -L. -lgainscalecalc -o $@
dynamic_driver: driver.c dynamiclib
$(CC) $(CFLAGS) driver.c -o $@ -L. -lgainscalecalc
staticlib: gainscalecalc_static.o
$(AR) $(ARFLAGS) libgainscalecalc.a gainscalecalc_static.o
$(RANLIB) libgainscalecalc.a
chmod 777 libgainscalecalc.a
dynamiclib: gainscalecalc_dynamic.o
$(CC) -shared -o libgainscalecalc.so gainscalecalc_dynamic.o
chmod 777 libgainscalecalc.so
Edit: Linking against the shared libraries compiles fine, I just haven't tested them out yet
© Stack Overflow or respective owner