3

I just want to make a little test with GLFW3 D binding. I create a new package using

dub init glfw3Test

Then I wrote a little test in glfw3Test\source\app.d

import derelict.glfw3.glfw3;

void main() 
{
    // Load the GLFW 3 library.
    DerelictGLFW3.load();
    if(DerelictGLFW3.isLoaded)
    {
    // Do something cool!

    }
}

And I modified the default JSON with:

{
"name": "glfw3Test",
"dependencies":
{
    "derelict-glfw3": "~master"
},
"configurations": [
    {
        "name": "glfw3Test",
        "targetType": "executable"
    }
]   
}

I built with dub build, everything went fine, but when I tred to launch the executable I got the following errors:

derelict.util.exception.SharedLibLoadException@../../../.dub/packages/derelict-util-1.0.2/source/derelict/util/exception.d(35): Failed to load one or more shared libraries:
libglfw.3.dylib - dlopen(libglfw.3.dylib, 2): image not found
libglfw3.dylib - dlopen(libglfw3.dylib, 2): image not found

I have also tried to compile my application manually without using DUB, but I got always the same problem.

It seems to look for the GLFW3 shared library, but I was thinking that the lib is statically linked by the built process.

I am on OS X 10.10 with Xcode 6 installed (DMD compiler 2.065)

Kill KRT
  • 1,101
  • 2
  • 17
  • 37
  • Well, it does not necessarily have to know the libglfw3.dylib at link-time. There's also the possibility to load this one at runtime using dlopen() and that's what it looks like. Do you have the libglfw3.dylib or the libglfw.3.dylib on your system? (Macports knows about it - so "sudo port install glfw" might do) – duselbaer Aug 24 '14 at 19:06
  • You're right. I've not noticed that building manually GLFW3 (with cmake) by default only build the libglfw3.a, so adding the option "-D BUILD_SHARED_LIBS=ON" building GLFW3 it built also the dylib! Thank you. – Kill KRT Aug 24 '14 at 19:58

1 Answers1

2

I've noticed that the default make process of GLFW3 (using cmake) does not create the dylib files. So I rebuilt GLFW with the following option:

cmake -D BUILD_SHARED_LIBS=ON

And then I made a make install, so now the file libglfw.dylib is correctly installed in /usr/local/lib

Thank to @duselbaer for make me noticed this problem.

Kill KRT
  • 1,101
  • 2
  • 17
  • 37