Wednesday, 15 September 2010

gcc - "Clean" linking with dynamic libraries (no LD_LIBRARY_PATH)? -



gcc - "Clean" linking with dynamic libraries (no LD_LIBRARY_PATH)? -

the title pretty much sums up. i'm trying link dynamic library when compiling another. here (short , humble) makefile:

all: src/ gcc -fpic -shared src/argsort.c -o libsort.so -lm gcc -fpic -shared src/kdtree.c -o libkdtree.so -l./ -lsort -lm

so i'm first building libsort.so. works great. i'm building libkdtree.so uses libsort.so. compilation goes great too, libkdtree.so unusable: here output of ldd libkdtree.so:

ldd libkdtree.so linux-vdso.so.1 => (0x00007fffcc54e000) libsort.so => not found libm.so.6 => /lib/x86_64-linux-gnu/libm.so.6 (0x00007f6b3c532000) libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007f6b3c172000) /lib64/ld-linux-x86-64.so.2 (0x00007f6b3ca57000)

if add together directory ld_library_path, works, link there , can utilize library. ld_library_path meant changed ? have no other selection ? mean share code others, , i'd not inquire people go add together .bashrc can run code. think don't understand -l does, since thought manually link library.

can either give me magic method overlooked, or crunch dreams of clean linking ?

thank !

gcc dynamic-linking ldd

No comments:

Post a Comment