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

Error: Dynamic Linking Error: Win32 error 126 When Calling a Go .so file with Node-ffi #617

Open
Humphryyy opened this issue Mar 24, 2021 · 3 comments

Comments

@Humphryyy
Copy link

var FFI = require('ffi-napi');
var Ref = require("ref-napi");
var Struct = require("ref-struct-napi")

const hwSharedLibPath = "./go-node-ffi";

/*
 * GoString ABI-compliant struct
 * See https://github.com/golang/go/wiki/cgo#go-strings-and-c-strings
 */
const goString = Struct({
    p: "string",
    n: "long",
});

class GoString extends goString {
    // GoString (cgo) -> JavaScript string
    static get(buffer, offset) {
        const _gs = goString.get(buffer, offset);
        return _gs.p.slice(0, _gs.n);
    }

    // JavaScript string -> GoString (cgo)
    static set(buffer, offset, value) {
        const _gs = new goString({
            p: value,
            n: value.length,
        });
        return goString.set(buffer, offset, _gs);
    }
}

const hw = FFI.Library(hwSharedLibPath, {
    HelloWorld: [GoString, []],
    Greet: [GoString, [GoString]],
    Add: ["int", ["int", "int"]],
});

const helloWorld = hw.HelloWorld();
console.log(helloWorld);

const addition = hw.Add(2, 4);
console.log(addition);

const greeting = hw.Greet("John");
console.log(greeting);

I've tried with a few other examples and I get the same error on them all.

I am trying to call a Go .so file and I am getting this error.

@MunzerDw
Copy link

MunzerDw commented Aug 1, 2021

Any updates on this issue?

@rajajwaliya
Copy link

i have getting same issue

@asjustas
Copy link

only libs built with golang 1.14 and not newer are working

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

4 participants