Discussion:
Can someone explain how glfw3.dll gets created?
WhatMeWorry via Digitalmars-d-learn
2014-10-13 20:21:55 UTC
Permalink
I have a simple GLFW3 program running in Visual D integrated
shell, that kept aborting at DerelictFLFW3.load() with a "failed
to load the shared libraries: glfw3.dll.'

So I found a glfw3.dll somewhere and moved it into the project
folder (I know this is bad technique) and that fixed the problem.

But now I'm wondering were this glfw3.dll came from.

I rebuildt the DerelictGLFW3 with dub as per the instructions.

E:\DerelictGLFW3-master>dub build
Building derelict-glfw3 ~master configuration "library", build
type debug.
Running dmd...

And I see
E:\DerelictGLFW3-master\source\derelict\glfw3\glfw3.d which is
used for compile time.

And the
E:\DerelictGLFW3-master\lib\DerelictGLFW3.lib which is the static
library required at link time.

But I couldn't find any glfw3.dll under the
E:\DerelictGLFW3-master path.


I did however, find these lines in the DerelictGLFW3/glfw3.d code:
...
static if( Derelict_OS_Windows )
enum libNames = "glfw3.dll";
. . .
class DerelictGLFW3Loader : SharedLibLoader {
public this() {
super( libNames );
}

protected override void loadSymbols() {
bindFunc( cast( void** )&glfwInit, "glfwInit" );
bindFunc( cast( void** )&glfwTerminate, "glfwTerminate" );
bindFunc( cast( void** )&glfwGetVersion, "glfwGetVersion"
);
bindFunc( cast( void** )&glfwGetVersionString,
"glfwGetVersionString" );
bindFunc( cast( void** )&glfwSetErrorCallback,
"glfwSetErrorCallback" );
...

But I don't believe this will create the glfw3.dll file? If I'm
correct, how, when and where is glfw3.dll created.

thanks as always.
Kapps via Digitalmars-d-learn
2014-10-13 20:29:44 UTC
Permalink
Derelict provides bindings to C libraries, and loads them at
runtime. So glfw3.dll is actually an existing C library (you can
get it at http://www.glfw.org/download.html), which Derelict
provides bindings for. Derelict / your code does not generate the
actual dll.
John Colvin via Digitalmars-d-learn
2014-10-13 20:31:05 UTC
Permalink
Post by WhatMeWorry via Digitalmars-d-learn
I have a simple GLFW3 program running in Visual D integrated
shell, that kept aborting at DerelictFLFW3.load() with a
"failed to load the shared libraries: glfw3.dll.'
So I found a glfw3.dll somewhere and moved it into the project
folder (I know this is bad technique) and that fixed the
problem.
But now I'm wondering were this glfw3.dll came from.
I rebuildt the DerelictGLFW3 with dub as per the instructions.
E:\DerelictGLFW3-master>dub build
Building derelict-glfw3 ~master configuration "library", build
type debug.
Running dmd...
And I see
E:\DerelictGLFW3-master\source\derelict\glfw3\glfw3.d which is
used for compile time.
And the
E:\DerelictGLFW3-master\lib\DerelictGLFW3.lib which is the
static library required at link time.
But I couldn't find any glfw3.dll under the
E:\DerelictGLFW3-master path.
I did however, find these lines in the DerelictGLFW3/glfw3.d
...
static if( Derelict_OS_Windows )
enum libNames = "glfw3.dll";
. . .
class DerelictGLFW3Loader : SharedLibLoader {
public this() {
super( libNames );
}
protected override void loadSymbols() {
bindFunc( cast( void** )&glfwInit, "glfwInit" );
bindFunc( cast( void** )&glfwTerminate, "glfwTerminate" );
bindFunc( cast( void** )&glfwGetVersion,
"glfwGetVersion" );
bindFunc( cast( void** )&glfwGetVersionString,
"glfwGetVersionString" );
bindFunc( cast( void** )&glfwSetErrorCallback,
"glfwSetErrorCallback" );
...
But I don't believe this will create the glfw3.dll file? If
I'm correct, how, when and where is glfw3.dll created.
thanks as always.
Derelict-glfw3 is just d bindings and a loader for the glfw3
library. The actual implementation of glfw (i.e. what you would
find in glfw3.dll) is a separate project, which you can find the
source for here http://www.glfw.org
Mike Parker via Digitalmars-d-learn
2014-10-14 08:49:19 UTC
Permalink
I have a simple GLFW3 program running in Visual D integrated shell, that
kept aborting at DerelictFLFW3.load() with a "failed to load the shared
libraries: glfw3.dll.'
So I found a glfw3.dll somewhere and moved it into the project folder (I
know this is bad technique) and that fixed the problem.
But now I'm wondering were this glfw3.dll came from.
Others have already answered your specific question, but I would just
like to point out that their answers are generally true for any Derelict
package you use. Derelict binds to C libraries, or C++ libraries with C
interfaces, so that they are usable from D. When you add Derelict to
your dub configuration, or in your Visual D build settings, all you are
getting are the D files allow you to interface with the C libraries --
you are not getting the C libraries themselves. On Windows, in most
cases you have to go out and either download a prebuilt binary or
download and compile the C source yourself. I say /most cases/ because
OpenGL will already be on your system as part of your graphics driver
and you may already have another library or two installed in your system
directories (like OpenAL, perhaps).

Furthermore, Derelict is a /dynamic/ binding in that it loads the shared
libraries at runtime and has absolutely no compile time dependency on
any of them. This is why you have to call DerelictFoo.load(). That looks
for the library on the system path and, if found, loads it into memory
so that you can start calling into it.

So if you are going to use GLFW, SDL, or anything else, you need to go
to that project's web site and use their documentation to understand how
to build (if they don't provide binaries) and use those libraries, then
make sure that the compiled DLLs are on the system path (meaning,
usually, in the executable's directory).

---
This email is free from viruses and malware because avast! Antivirus protection is active.
http://www.avast.com

Loading...