How to link to libdl under linux
Marco Leise
Marco.Leise at gmx.de
Mon Dec 16 05:31:32 PST 2013
Am Mon, 16 Dec 2013 11:09:52 +0100
schrieb "MrSmith" <mrsmith33 at yandex.ru>:
> > You're still not linking ld properly. It would help
> > tremendously if you could show the command line you're using.
> > Otherwise all people can do is make guesses about what *might*
> > be wrong.
>
> Oh, right.
> Here is first with "/usr/lib32/libdl.a" -L-ldl
>
> andrey at andress-ubuntu:~/anchovy$ dmd -debug -gc -m32
> "examples/fpshelper.d" "examples/main.d" -I"import" -I"deps/dlib"
> -I"deps/derelict-fi-master/source"
> -I"deps/derelict-sdl2-master/source"
> -I"deps/derelict-ft-master/source"
> -I"deps/derelict-gl3-master/source"
> -I"deps/derelict-glfw3-master/source"
> -I"deps/derelict-util-1.0.0/source" "lib/debug/libgui.a"
> "lib/debug/libgraphics.a" "lib/debug/libcore.a"
> "lib/debug/libutils.a" "deps/dlib/libdlib.a"
> "deps/derelict-fi-master/lib/libDerelictFI.a"
> "deps/derelict-ft-master/lib/libDerelictFT.a"
> "deps/derelict-gl3-master/lib/libDerelictGL3.a"
> "deps/derelict-glfw3-master/lib/libDerelictGLFW3.a"
> "deps/derelict-util-1.0.0/lib/libDerelictUtil.a"
> "/usr/lib32/libdl.a" -L-ldl -of"bin/guidemo"
>
> deps/derelict-fi-master/lib/libDerelictFI.a(sharedlib_416_4ee.o):
> In function `_D8derelict4util9sharedlib13LoadSharedLibFAyaZPv':
> /home/andrey/anchovy/deps/derelict-fi-master/../../../.dub/packages/derelict-util-1.0.0/source/derelict/util/sharedlib.d:60:
> warning: Using 'dlopen' in statically linked applications
> requires at runtime the shared libraries from the glibc version
> used for linking
> /usr/lib32/libdl.a(dlopen.o): In function `dlopen':
> (.text+0x1b): undefined reference to `__dlopen'
> /usr/lib32/libdl.a(dlclose.o): In function `dlclose':
> (.text+0x1): undefined reference to `__dlclose'
> /usr/lib32/libdl.a(dlsym.o): In function `dlsym':
> (.text+0x1b): undefined reference to `__dlsym'
> /usr/lib32/libdl.a(dlerror.o): In function `dlerror':
> (.text+0x1): undefined reference to `__dlerror'
> collect2: error: ld returned 1 exit status
> --- errorlevel 1
>
> Second with -L-ldl only
>
> andrey at andress-ubuntu:~/anchovy$ dmd -debug -gc -m32
> "examples/fpshelper.d" "examples/main.d" -I"import" -I"deps/dlib"
> -I"deps/derelict-fi-master/source"
> -I"deps/derelict-sdl2-master/source"
> -I"deps/derelict-ft-master/source"
> -I"deps/derelict-gl3-master/source"
> -I"deps/derelict-glfw3-master/source"
> -I"deps/derelict-util-1.0.0/source" "lib/debug/libgui.a"
> "lib/debug/libgraphics.a" "lib/debug/libcore.a"
> "lib/debug/libutils.a" "deps/dlib/libdlib.a"
> "deps/derelict-fi-master/lib/libDerelictFI.a"
> "deps/derelict-ft-master/lib/libDerelictFT.a"
> "deps/derelict-gl3-master/lib/libDerelictGL3.a"
> "deps/derelict-glfw3-master/lib/libDerelictGLFW3.a"
> "deps/derelict-util-1.0.0/lib/libDerelictUtil.a" -L-ldl
> -of"bin/guidemo"
>
> deps/derelict-fi-master/lib/libDerelictFI.a(sharedlib_416_4ee.o):
> In function `_D8derelict4util9sharedlib13LoadSharedLibFAyaZPv':
> /home/andrey/anchovy/deps/derelict-fi-master/../../../.dub/packages/derelict-util-1.0.0/source/derelict/util/sharedlib.d:60:
> undefined reference to `dlopen'
> deps/derelict-fi-master/lib/libDerelictFI.a(sharedlib_417_5d1.o):
> In function `_D8derelict4util9sharedlib15UnloadSharedLibFPvZv':
> /home/andrey/anchovy/deps/derelict-fi-master/../../../.dub/packages/derelict-util-1.0.0/source/derelict/util/sharedlib.d:64:
> undefined reference to `dlclose'
> deps/derelict-fi-master/lib/libDerelictFI.a(sharedlib_418_396.o):
> In function `_D8derelict4util9sharedlib9GetSymbolFPvAyaZPv':
> /home/andrey/anchovy/deps/derelict-fi-master/../../../.dub/packages/derelict-util-1.0.0/source/derelict/util/sharedlib.d:68:
> undefined reference to `dlsym'
> deps/derelict-fi-master/lib/libDerelictFI.a(sharedlib_419_463.o):
> In function `_D8derelict4util9sharedlib11GetErrorStrFZAya':
> /home/andrey/anchovy/deps/derelict-fi-master/../../../.dub/packages/derelict-util-1.0.0/source/derelict/util/sharedlib.d:72:
> undefined reference to `dlerror'
> collect2: error: ld returned 1 exit status
> --- errorlevel 1
Do you have the 32-bit version of libdl installed?
What does this command output?:
find /lib /lib32 /usr/lib /usr/lib32 -name "libdl*.so*"
-type f -exec file {} ";"
For me it prints
/lib32/libdl-2.15.so: ELF 32-bit LSB shared object, Intel 80386, version 1 (SYSV), dynamically linked (uses shared libs), for GNU/Linux 2.6.9, stripped
so there is a libdl for 32-bit in /lib32.
If you have one as well, you'll probably need to call the
linker with the verbose option:
dmd -debug -gc -m32
"examples/fpshelper.d" "examples/main.d" -I"import" -I"deps/dlib"
-I"deps/derelict-fi-master/source"
-I"deps/derelict-sdl2-master/source"
-I"deps/derelict-ft-master/source"
-I"deps/derelict-gl3-master/source"
-I"deps/derelict-glfw3-master/source"
-I"deps/derelict-util-1.0.0/source" "lib/debug/libgui.a"
"lib/debug/libgraphics.a" "lib/debug/libcore.a"
"lib/debug/libutils.a" "deps/dlib/libdlib.a"
"deps/derelict-fi-master/lib/libDerelictFI.a"
"deps/derelict-ft-master/lib/libDerelictFT.a"
"deps/derelict-gl3-master/lib/libDerelictGL3.a"
"deps/derelict-glfw3-master/lib/libDerelictGLFW3.a"
"deps/derelict-util-1.0.0/lib/libDerelictUtil.a"
-L--verbose -L-ldl
-of"bin/guidemo"
By the way, can you recompile everything in 64-bit or do you
have a 32-only system. In that case you don't require the -m32
flag.
--
Marco
More information about the Digitalmars-d-learn
mailing list