Thread overview
Cannot get Derelict to work
Feb 03, 2016
Whirlpool
Feb 03, 2016
Mike Parker
Feb 03, 2016
Mike Parker
Feb 03, 2016
Mike Parker
Feb 03, 2016
Mike Parker
Feb 03, 2016
Whirlpool
Feb 07, 2016
Whirlpool
Feb 07, 2016
Mike Parker
Feb 07, 2016
Mike Parker
Feb 07, 2016
Whirlpool
February 03, 2016
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

- 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 ?

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.


- 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)
	
After that, I've tried compiling derelict-util and derelict-glfw3 in AppData, because there seemed to be no lib files. But isn't one of the points of using DUB precisely that users don't have to compile the dependency libs themselves ?

I'd really need a tutorial or help about that. I could only find a couple of old posts or articles from years ago.

Thank you
February 03, 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.
February 03, 2016
On Wednesday, 3 February 2016 at 13:04:54 UTC, Mike Parker wrote:


> 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.

Actually, they do provide prebuilt binaries for Windows now [1] . I'm so used to compiling it myself I forgot all about that.

[1] http://www.glfw.org/download.html
February 03, 2016
On Wednesday, 3 February 2016 at 13:07:51 UTC, Mike Parker wrote:
> On Wednesday, 3 February 2016 at 13:04:54 UTC, Mike Parker wrote:
>
>
>> 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.
>
> Actually, they do provide prebuilt binaries for Windows now [1] . I'm so used to compiling it myself I forgot all about that.
>
> [1] http://www.glfw.org/download.html

And just to be clear, the typical thing to do on Windows is to put this in the same directory as the binary. I like to set a targetPath directive in my dub.sdl/json for a bin directory so that the executable is created there. Then I just save the dll in the bin directory.

// dub.json
"targetPath": "bin",

// dub.sdl
targetPath "bin"

So then the project tree looks like:

- myproj
-- bin
--- glfw3.dll
-- source
--- app.d
-- dub.sdl

Your exectuable will be output to the bin directory and DerelictGLFW3.load should find the DLL just fine.
February 03, 2016
On Wednesday, 3 February 2016 at 13:04:54 UTC, Mike Parker wrote:

>> - First I tried to create a VisualD project on Windows, and to manually compile derelict-util and derelict-glfw3:

FYI, this thread motivated me to revisit the manual compilation instructions in the Derelict docs [1]. I've outline a different approach using dub fetch that is probably easier to get started with.

[1] http://derelictorg.github.io/compiling.html#nodub

February 03, 2016
Thank you so much ! Thanks to your instructions, it is working for me now with Visual Studio and I can run the first example of GLFW's documentation :) I'll try on Fedora at a later time
February 07, 2016
Hi,

Sorry, I have a problem again :)

I tried to compile this example :
http://www.glfw.org/docs/latest/quick.html#quick_example
which required to add derelict-gl3

My code is currently this : http://pastebin.com/A5seZmX6

It compiles without errors, but crashes immediately with again exceptions of the form :
First-chance exception: derelict.util.exception.SymbolLoadException Failed to load OpenGL symbol [glGetnTexImage] at ..\AppData\Roaming\dub\packages\derelict-util-2.0.4\source\derelict\util\exception.d(35)


The output of the Visual Studio console is this :

C:\Windows\SysWOW64\winmmbase.dll unloaded.
C:\Windows\SysWOW64\winmmbase.dll unloaded.
C:\Windows\SysWOW64\winmmbase.dll unloaded.
C:\Windows\SysWOW64\atigktxx.dll unloaded.
First-chance exception: derelict.util.exception.SymbolLoadException Failed to load OpenGL symbol [glGetnTexImage] at ..\AppData\Roaming\dub\packages\derelict-util-2.0.4\source\derelict\util\exception.d(35)

Unhandled exception: derelict.util.exception.SymbolLoadException Failed to load OpenGL symbol [glGetnTexImage] at ..\AppData\Roaming\dub\packages\derelict-util-2.0.4\source\derelict\util\exception.d(35)

First-chance exception: derelict.util.exception.SymbolLoadException Failed to load OpenGL symbol [glGetnCompressedTexImage] at ..\AppData\Roaming\dub\packages\derelict-util-2.0.4\source\derelict\util\exception.d(35)

Unhandled exception: derelict.util.exception.SymbolLoadException Failed to load OpenGL symbol [glGetnCompressedTexImage] at ..\AppData\Roaming\dub\packages\derelict-util-2.0.4\source\derelict\util\exception.d(35)

First-chance exception: 0xc0000005: Access violation
Unhandled exception: 0xc0000005: Access violation


Is it the same kind of problem as before ? If my understanding is correct [1], I need to link with the OpenGL DLL, don't I ? I found that I have an opengl32.dll file in C:\Windows\System32, and tried adding the path to it in the linker configuration of Visual Studio. I've also tried copying it to my bin target folder, but it still doesn't work. I also tried compiling in 64-bit mode, but I get different errors :
C:\Windows\System32\winmmbase.dll unloaded.
C:\Windows\System32\winmmbase.dll unloaded.
C:\Windows\System32\winmmbase.dll unloaded.
C:\Windows\System32\atig6txx.dll unloaded.
First-chance exception: 0xc0000096: Privileged instruction
Unhandled exception: 0xc0000096: Privileged instruction
The thread 0x11cc has exited with code 255 (0xff).
The thread 0x3d0 has exited with code 255 (0xff).
The thread 0x12c0 has exited with code 255 (0xff).
The program '[8112] derelicttest.exe' has exited with code 255 (0xff).

I am aware that this example from GLFW uses deprecated functions from OpenGL 2, is that the problem ? (I will try OpenGL 4 with the tutorials at [2] soon)

Please can you help me, thanks in advance

[1] http://derelictorg.github.io/dynstat.html
[2] http://antongerdelan.net/opengl/


February 07, 2016
On Sunday, 7 February 2016 at 12:55:30 UTC, Whirlpool wrote:


> Is it the same kind of problem as before ? If my understanding is correct [1], I need to link with the OpenGL DLL, don't I ? I found that I have an opengl32.dll file in C:\Windows\System32, and tried adding the path to it in the linker configuration of

No, you do not need to link with OpenGL. As the documentation link you provided explains, Derelict bindings are all dynamic, so there is no link time dependency on the bound library. It's all runtime, which is why you have to call DerelictFoo.load.

> I am aware that this example from GLFW uses deprecated functions from OpenGL 2, is that the problem ? (I will try OpenGL 4 with the tutorials at [2] soon)
>

The problem is right there in the exception you posted. That's what exceptions are for.

> First-chance exception: derelict.util.exception.SymbolLoadException Failed to load OpenGL symbol [glGetnTexImage] at ..\AppData\Roaming\dub\packages\derelict-util-2.0.4\source\derelict\util\exception.d(35)

You can see the exception thrown is a derelict.util.exception.SymbolLoadException. As explained in the Derelict documentation on load failures [1], this is thrown when a symbol cannot be found in a DLL. It means that the loader found the DLL just fine, but a function it expected to find wasn't there. Here, that function is glGetnTexImage. So it has nothing to do with your code, but is a problem in the DLL.

Normally, this means that you're trying to load version of a DLL that is older than the binding you are using. However, OpenGL is a special case, which is why it has the reload method. It will only attempt to load the version of OpenGL supported by your driver. This means that if it doesn't find a function it expects, then either your driver is lying or DerelictGL3 is broken.

glGetnTexImage is part of the OpenGL 4.5 specification. I'm going to make a guess that you are using an AMD (formerly ATI) card. There is an open issue in the Derelict repo regarding their latest drivers and 4.5 support [2]. It's not the first time it's been reported to me. It seems the driver claims to support 4.5, but some of the 4.5 functions fail to load. The way to work around this is to specify a maximum OpenGL version as the second of two arguments in the call to reload.

```
DerelictGL3.reload(GLVersion.None, GLVersion.GL44);
```

The first argument is the minimum version to load, which always defaults to None. In effect, this says load everything from 1.2 (1.1 is loaded in the call to DerelictGL3.load) up to the highest version the driver supports or up to 4.4, whichever is lower. This line should be enough to work around the AMD driver issue.

Another point to make is that if you need deprecated functions, DerelictGL3 is not what you want. You should import derelict.opengl3.gl and use DerelictGL.load/reload instead. It includes all of the deprecated functions. Just make sure you have created a context that allows you to access the deprecated stuff. As far as I know, 4.0+ (perhaps even 3.3) are core only. Note that you *do not* need to load both DerelictGL3 and DerelictGL, as the latter handles everything for you.

[1] http://derelictorg.github.io/using/fail.html
[2] https://github.com/DerelictOrg/DerelictGL3/issues/43
[3] https://github.com/DerelictOrg/DerelictGL3/blob/master/source/derelict/opengl3/gl3.d#L80
February 07, 2016
On Sunday, 7 February 2016 at 14:04:49 UTC, Mike Parker wrote:

>
> Another point to make is that if you need deprecated functions, DerelictGL3 is not what you want. You should import derelict.opengl3.gl and use DerelictGL.load/reload instead. It includes all of the deprecated functions. Just make sure you have created a context that allows you to access the deprecated stuff. As far as I know, 4.0+ (perhaps even 3.3) are core only. Note that you *do not* need to load both DerelictGL3 and DerelictGL, as the latter handles everything for you.

Which I see you are already doing! I should have looked at your code first.
February 07, 2016
Thank you very much for your explanations and patience :) I indeed have an AMD Radeon HD 7870 card, and using 4.4 as the max version fixes my problem !