I am trying to build an application(libnodeapplication) which is dependent on a shared library(libnode.so) which in turn depends on another shared library(libgentoo-5.so.100) which I have pasted at the same location as the libnode(inside /usr/lib/)
Problem is second dependent library is symbolically linked to another file
what changes are needed in the compile command to build it successfully(for symbolically linkd files refrened in the shared library)
I tried with -Wl,-rpath=<path to usr/lib/path_to_libgentoo-5.so.100 (also without file name) as well :
command2 :
gcc main.o -o libnodeapplication -L/usr/lib/-lnode -Wl,-rpath=/usr/lib/
error
below is the error
ld: warning: libgentoo-5.so.100, needed by /usr/lib/libnode.so, not found (try using -rpath or -rpath-link)
usr/lib/libnode.so: undefined reference to `symbol1 in libgentoo-5.so.100'
usr/lib/libnode.so: undefined reference to `symbol2 in libgentoo-5.so.100'
usr/lib/libnode.so: undefined reference to `symbol3 in libgentoo-5.so.100'
.
.
.
and so on
(for simplicity i have used gcc instead of arm linux cross compiler) so my end application is libnodeapplication which depends on shared lib => libnode.so
libnode.so is being built using the libgentoo-5.so.100 (which is present in the /usr/lib and symbolically linked to libgentoo-5.so.100.20.0 : libgentoo-5.so.100 -> libgentoo-5.so.100.20.0)
I use this command1 :
gcc obj1.o obj2.o obj3.o -shared -o libnode.so /usr/lib/libgentoo-5.so.100
When i try to use the objdum -t libnode.so , I can find all those symbols which are reported as undefined symbols when I try to build the libnodeapplication by above command2
My Makefile(for libnodeapplication)
CC=<path to tool chain>arm-linux-gnueabihf-gcc
CFLAGS=-Wall
LIB_NAME=-lnode
LIBS=-L$(TARGET_DIR)/usr/lib
INCS=-I./include/
OBJS=libnodeapplication.o
libnodeapplication: $(OBJS)
$(CC) $(OBJS) -o libnodeapplication $(LIBS) $(LIB_NAME)
main.o: main.c
$(CC) $(INCS) $(CFLAGS) -c $< -o $@
clean:
-rm -rf *.o libnodeapplication
-rm -rf $(TARGET_DIR)/root/libnodeapplication
install:
cp libnodeapplication $(TARGET_DIR)/root
chmod +x $(TARGET_DIR)/root/libnodeapplication
Make file for libnode.so
CC=<path to tool chain>arm-linux-gnueabihf-gcc
CFLAGS=-Wall -fPIC
INCS=-I./include/
LIBS=$(TARGET_DIR)/usr/lib/libgentoo-5.so.100
OBJS=libnode.o helper.o
libnode: $(OBJS)
$(CC) $(OBJS) -shared -o a.so $(LIBS)
libnode.o: libnode.c
$(CC) $(INCS) $(CFLAGS) -c $< -o $@
helper.o: helper.c
$(CC) $(INCS) $(CFLAGS) -c $< -o $@
clean:
-rm -rf *.o
-rm -rf libnode.so
-rm -rf $(TARGET_DIR)/usr/lib/libnode.so
-rm -rf $(TARGET_DIR)/usr/include/libnode.h
install:
-cp libnode.so $(TARGET_DIR)/usr/lib
-cp libnode.h $(TARGET_DIR)/usr/include