How to link to libdl under linux

MrSmith mrsmith33 at yandex.ru
Mon Dec 16 02:09:52 PST 2013


> 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


More information about the Digitalmars-d-learn mailing list