unbornchikken / NOOOCL

Node.js Object Oriented OpenCL Bindings
MIT License
81 stars 9 forks source link

We need a tiny change when using NOOOCL in OSX #10

Closed wuxianliang closed 8 years ago

wuxianliang commented 9 years ago

In OSX, OpenCL's path is

/System/Library/Frameworks/OpenCL.framework/OpenCL

When I modify the 41th line of dynamic_library.js in ffi.lib

this._handle = dlopen('/System/Library/Frameworks/OpenCL.framework/OpenCL', mode);

it works. Similar problem happens in opencl-ruby too. https://github.com/Nanosim-LIG/opencl-ruby/issues/1

unbornchikken commented 9 years ago

Hi,

So do you say that the actual dynamic library file is OpenCL in the directory of /System/Library/Frameworks/OpenCL.framework? Is it in the PATH?

wuxianliang commented 9 years ago

Actually I do not understand the file or path, I just use Nooocl with npm package in Meteor project. If I did not change anything, I receive a error

Dynamic Linking Error: dlopen(OpenCL.dylib, 2): image not found

Then I found opencl-ruby had such problem too. The way to fix is adding the path in an appropriate place. I found

this._handle = dlopen('/System/Library/Frameworks/OpenCL.framework/OpenCL', mode);

this one works. In my understanding, the problem is

this.libName = /^win/.test(process.platform) ? "OpenCL" : "libOpenCL.so";

this line in cl11.js did not make Nooocl find the correct OpenCL in OSX. OSX case should be different from Linux's, I think.

unbornchikken commented 9 years ago

Could you test it with:

this.libName = (process.platform === "win32" || process.platform === "darwin") ? "OpenCL" : "libOpenCL.so";
wuxianliang commented 9 years ago

it does not work.

unbornchikken commented 9 years ago

And with:

this.libName = process.platform === "win32" ? "OpenCL" : (process.platform === "darwin" ? "/System/Library/Frameworks/OpenCL.framework/OpenCL" : "libOpenCL.so");
wuxianliang commented 9 years ago

it does not work, because there are codes that append .dylib to the string of path.

wuxianliang commented 9 years ago

in ffi.library.js

wuxianliang commented 9 years ago

just modify library.EXT is ok, in darwin case we do not need append anything.

unbornchikken commented 9 years ago

Well, then NOOOCL side, we gotta go with:

this.libName = (process.platform === "win32" || process.platform === "darwin") ? "OpenCL" : "libOpenCL.so";

But we need and ffi PR to make this work. Will look into this.

Paxa commented 8 years ago

As temporary solution I create symlink in current folder of my nodejs code:

ln -s /System/Library/Frameworks/OpenCL.framework/OpenCL ./libOpenCL.so.dylib
unbornchikken commented 8 years ago

As of 0.12.0, the is no more library path tampering anymore.