Cannot get Derelict to work

Mike Parker via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Wed Feb 3 05:04:54 PST 2016


On Wednesday, 3 February 2016 at 12:18:17 UTC, Whirlpool wrote:
> Hi, I'd like to use Derelict, more specifically the GLFW 
> package, but so far I have been unable to make it work. (I 
> posted in the IDE section but didn't get a reply (link below), 
> and since the Derelict forum seems not to exist anymore, I post 
> here. I hope it is OK to do so)
>
> Things I tried :
>
> - First I tried to create a VisualD project on Windows, and to 
> manually compile derelict-util and derelict-glfw3: 
> http://forum.dlang.org/post/ssibsuuhuaswaelxzpxt@forum.dlang.org

Your problem there is that you have misconfigured Visual D. The 
DerelictGLFW3 and DerelictUtil *source* files need to be on the 
import path. The libraries need to be on the library path. Don't 
confuse importing with linking. The former happens at *compile 
time*. The compiler needs to know where to find the source files 
so it can determine which symbols are available to your module. 
That's what the import path is for. At *link time*, which comes 
after the compiler has generated object files, the linker will 
take all of the object files and any libraries you need and 
combine them into an executable. Setting the library path in your 
IDE configuration will allow the IDE to ultimately pass that path 
to the linker so that it will know where to find the library 
files. This is the same for any IDE you may use. The only 
difference will be in the details, i.e. where and how you set the 
import and library paths.


> - then, I tried on Fedora 23, which has packages in its 
> repositories for LDC and Derelict. I first tried to use a 
> command such as this one :
> ldc2 -I=/usr/include/d/derelict -L=DerelictUtil 
> -L=DerelictGLFW3 glfw_test.d
> /usr/bin/ld: ne peut pas trouver DerelictUtil: Aucun fichier ou 
> dossier de ce type (which means "cannot find DerelictUtil. No 
> such file or directory")
> /usr/bin/ld: ne peut pas trouver DerelictGLFW3: Aucun fichier 
> ou dossier de ce type
> collect2: erreur: ld a retourné 1 code d'état d'exécution
> Error: /usr/bin/gcc failed with status: 1
>
> I indeed don't have a /usr/bin/ld directory. Is the command I 
> tried correct ?

/usr/bin/ld is not a directory. ld is the GNU linker, which you 
will have if you've installed GCC. I'm not an LDC user, but I 
will guess your problem is in the command line. With GCC, -L is 
used to pass the library *path* to the linker. Infivusal 
libraries are passed with -l. And usually, there's no '=', but I 
don't know if that's the problem here or not. You'll need to look 
up what command line options LDC supports specifically.

>
> Still on Fedora, I've also tried with DUB :
> $ dub build
> Performing "debug" build using ldc2 for x86_64.
> derelict-util 2.0.4: building configuration "library"...
> Error: failed to create path to file: 
> .dub/obj/../../.dub/packages/derelict-util-2.0.4/.dub/build/library-debug-linux.posix-x86_64-ldc_0-A2036AF2F4C2D6CD8A2817C4F5C50907/libDerelictUtil.a
> No such file or directory
> ldc2 failed with exit code 1.

What were you running dub build on here? Just derelict-util or 
your project?


>
> - trying again with DUB on Windows 10, I created a dub project, 
> added derelict-util and derelict-glfw3 as dependencies in the 
> dub.sdl file, and then used "dub generate visuald", but when I 
> try to build in Visual Studio, I get the following kind of 
> exceptions :
>
> First-chance exception: 
> derelict.util.exception.SharedLibLoadException Failed to load 
> one or more shared libraries:
>
> 	glfw3.dll - Le module spécifié est introuvable. (The specified 
> module cannot be found.) at 
> ..\AppData\Roaming\dub\packages\derelict-util-2.0.4\source\derelict\util\exception.d(35)

The good news is that you've compiled and linked DerelictGLFW3 
and DerelictUtil just fine. That's why this is the recommended 
approach, as it's so easy. However, you still actually need the 
GLFW3 DLL on your system. DerelictGLFW3 is a binding to GLFW3, 
nothing more. It's a dynamic binding, so you don't need to mess 
with the GLFW library at compile time. But you still need the 
GLFW DLL at runtime. You can go to glfw.org and download the 
latest release. Unfortunately, they do not provide a binary 
distribution, so you will have to build the DLL from source or 
find somewhere that makes it available prebuilt DLLs available 
for you.


More information about the Digitalmars-d-learn mailing list