Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can't get examples working, Luajit 2.0.4, Os X 10.9.5 #1

Closed
Sakari369 opened this issue Dec 7, 2015 · 5 comments
Closed

Can't get examples working, Luajit 2.0.4, Os X 10.9.5 #1

Sakari369 opened this issue Dec 7, 2015 · 5 comments

Comments

@Sakari369
Copy link

Hello, I was testing out your Luajit GLFW bindings.
Running on Mac Os X 10.9.5, with Luajit 2.0.4 installed from MacPorts to /opt/local

When I try to run the examples, I just get this error message:

sakari@iViper /t/luajit-glfw (master)> luajit examples/base.lua
luajit: ./glfw.lua:972: dlopen(libglfw3.dylib, 5): image not found
stack traceback:
    [C]: in function 'load'
    ./glfw.lua:972: in function <./glfw.lua:969>
    examples/base.lua:1: in main chunk
    [C]: at 0x010ec83dca

So apparently Luajit can't find my glfw libraries. I have also installed libglfw 3.1.2 from MacPorts under /opt/local, as shown here:

sakari@iViper /t/luajit-glfw (master)> ls -l /opt/local/lib/libglfw.*
-rwxr-xr-x  1 root  admin  89396 Oct 16 19:54 /opt/local/lib/libglfw.3.1.dylib*
lrwxr-xr-x  1 root  admin     17 Oct 16 19:54 /opt/local/lib/libglfw.3.dylib@ -> libglfw.3.1.dylib
lrwxr-xr-x  1 root  admin     15 Oct 16 19:54 /opt/local/lib/libglfw.dylib@ -> libglfw.3.dylib

I tried also changing the code to directly point to the library by changing the 'name' variable, and also tried copying the libraries to the current working directory, no luck.

Can you tell me what I'm missing here? Thanks!

@Playermet
Copy link
Owner

Hi!
I don't have Mac Os X, but i know several solutions that working on Linux Mint.

First way. Put library (libglfw.so in my case) in directory with example files.

-- './libglfw.3.1.dylib' in your case
local glfw = require 'glfw' ('./libglfw.so')

Second way. Using precise path to library.

-- '/opt/local/lib/libglfw.3.1.dylib' in your case
local glfw = require 'glfw' ('/usr/local/lib/libglfw.so')

Third way. Function ffi.load doesn’t use package.cpath, but we can easy solve it.

-- '/opt/local/lib/?.dylib' in your case, and 'libglfw.3.1' as name
-- also, package.cpath may be used instead of libpath
local libpath = '/usr/local/lib/?.so;'
local glfw = require 'glfw' (package.searchpath('libglfw', libpath))

@Sakari369
Copy link
Author

Thanks @Playermet , I got it working with this:

local glfw = require 'glfw' ('/opt/local/lib/libglfw.3.dylib')

Didn't realize you can change the library it points to on the another argument.
Thanks for the quick answer!

Although when trying to run the examples, they just crash on my Os X system, maybe because the rendering is not doing anything? Not sure.

@Playermet
Copy link
Owner

Examples should show black screen, without crashes.

Try insert this line before glfw.Init call:

glfw.SetErrorCallback(print)

What printed to the console after run?

@Sakari369
Copy link
Author

Actually now that I test again, the examples work, showing the empty buffer (black with some glitches from the uninitialized memory). Strange. Anyway, I guess this can be closed, thanks!

@Playermet
Copy link
Owner

You're welcome!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants