TooTallNate / ref

Turn Buffer instances into "pointers"
http://tootallnate.github.com/ref
451 stars 141 forks source link

lazy symbol binding failed: Symbol not found #113

Open 7934345 opened 5 years ago

7934345 commented 5 years ago

Hi, I'm a starter of electron and nodejs, also ffi

ox : Darwin mac-dev.local 18.5.0 Darwin Kernel Version 18.5.0: Mon Mar 11 20:40:32 PDT 2019; root:xnu-4903.251.3~3/RELEASE_X86_64 x86_64 node: v10.15.2 x64 npm: 6.4.1

package.json { "name": "helloworld", "version": "1.0.0", "description": "Hello Electron", "main": "main.js", "scripts": { "npm-install": "npm i", "package": "electron-packager . HelloElectron --all", "start": "electron .", "bs": "npm build && npm start", "postinstall": "electron-builder --mac --x64 install-app-deps" }, "author": "Jack Martin", "license": "ISC", "repository": { "private": true }, "devDependencies": { "asar": "^1.0.0", "electron": "4.0.3", "electron-builder": "^20.39.0", "electron-packager": "^13.1.1", "ffi": "^2.3.0" }, "dependencies": { "ref": "^1.3.5" } }

main.js just create a basic window and load index.html

index.html

<body>
    <div>
        <button type="button" onclick="hello()">Call Hello</button>
    </div>
    <span id="hello"></span>

    <script>
        window.onload = function () {
            try {
                var ref = require('ref');
                // let ffi = require('ffi');
                // console.log('fii.Library result:', ffi);
                // window.lib = ffi.Library('test.dylib', {
                //     hello: ['int', ['pointer']]
                // });
                // console.log('fii.Library result:', window.lib);
            } catch (error) {
                console.error('ffi.Library', error);
            }
        };
        function hello() {
            // let callback = require('ffi').Callback('void', ['int', 'string'], function (size, reply) {
            //     document.getElementById('hello').innerHTML = reply;
            // });
            // window.lib.hello(callback);
        }
    </script>

</body>

npm i works well npm start with the error below

dyld: lazy symbol binding failed: Symbol not found: __ZN2v811HandleScope12CreateHandleEPNS_8internal10HeapObjectEPNS1_6ObjectE
  Referenced from: /Users/jack/Desktop/test/electron/HelloWorld/node_modules/ref/build/Release/binding.node
  Expected in: flat namespace

dyld: Symbol not found: __ZN2v811HandleScope12CreateHandleEPNS_8internal10HeapObjectEPNS1_6ObjectE
  Referenced from: /Users/jack/Desktop/test/electron/HelloWorld/node_modules/ref/build/Release/binding.node
  Expected in: flat namespace

I find nothing help when searching the google.

Its nothing to do with the ffi but the ref its self.

Could anyone help me of out this?

feshfans commented 4 years ago

Hello, have you solved your problem? I had the same problem

feshfans commented 4 years ago

https://electronjs.org/docs/tutorial/using-native-node-modules 执行下面这条命令就可解决: ./node_modules/.bin/electron-rebuild