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

Linking a library with an addon #892

Closed
toly-k opened this issue Dec 5, 2014 · 6 comments
Closed

Linking a library with an addon #892

toly-k opened this issue Dec 5, 2014 · 6 comments

Comments

@toly-k
Copy link

toly-k commented Dec 5, 2014

I am writing an addon that wraps a C++ library. Unfortunately I am having difficulties loading that library with atom-shell.
This is my binding.gyp:

{
    "targets": [{
        "target_name": "addon",
        "sources": ["test.cc"],
        "include_dirs": [
            "Headers",
        ],
        "link_settings": {
            "libraries": [
                "-lmylib.lib",
            ],
            "library_dirs": [
                "Lib",
            ],
        },
    }]
}

It works for tests with node test.js

//test.js
var addon = require('./build/Release/addon');

However when I do the same with atom.exe test.js it throws an exception "The specified module could not be found". Removing dependency on the library fixes the error, so I assume it is looking for mylib.lib in the wrong place?
A lot of the answers I found have an absolute path to a library i.e. /usr/lib
Is it possible to keep the library file locally?

@zcbenz
Copy link
Contributor

zcbenz commented Dec 5, 2014

Can you try adding .node in the filename? Like require('./build/Release/addon.node');

@toly-k
Copy link
Author

toly-k commented Dec 6, 2014

@zcbenz I get the same error.
untitled

However if I remove dependency on mylib.lib from the binding.gyp and commenting out relevant code from the addon, test.js executes just fine. So I suspect the error signals that atom can't find mylib.lib?

@zcbenz
Copy link
Contributor

zcbenz commented Dec 8, 2014

Can you check if the build/Release/addon.node exists? It is possible that the build failed when mylib.lib was present.

@anaisbetts
Copy link
Contributor

This message also gets thrown when you rename the EXE (#713) or any other import fails when loading the DLL. Check via depends.exe (http://www.dependencywalker.com/) if all the imports are legit.

@toly-k
Copy link
Author

toly-k commented Dec 9, 2014

@paulcbetts Thanks, that helped.

@toly-k toly-k closed this as completed Dec 9, 2014
@dougludlow
Copy link

@paulcbetts thanks for the suggestion to use Dependency Walker. I figured out the module I was importing was missing a .dll: http://stackoverflow.com/questions/41253450/error-the-specified-module-could-not-be-found/

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