Dynamically linked libraries giving me Library not loaded: Image not found
Open
Nobody has claimed this yet.
nodejs/nan
- Dominant language
- Python
- Stars
- 10.7k
- Forks
- 1.9k
- Avg merge
- 1d 4h
- Merged PRs (30d)
- 5
Description
- Node Version: node v15.11.0, npm 7.6.0, node-gyp v7.1.2, electron 9.3.3
- Platform: macOS Catalina
- Compiler:
Apple clang version 12.0.0 (clang-1200.0.32.29)
Target: x86_64-apple-darwin19.6.0
Thread model: posix
InstalledDir: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin
I'm trying to include a dynamically linked library like so.
{
"targets": [
{
"target_name": "addon",
"sources": [ "addon.cc","file2.cpp" ],
"include_dirs": [
"<!(node -e \"require('nan')\")",
"./include"
],
"libraries": [
"/Users/me/Documents/.../library.a",
"-L/Users/me/Documents/.../", "-lMyLibrary"
],
'ldflags': [
],
}
]
}
Compilation is successful, however runtime gives me error.
App threw an error during load
Error: dlopen(/Users/me/Documents/.../build/Release/addon.node, 1): Library not loaded: @executable_path/libMyLibrary.dylib
Referenced from: /Users/me/Documents/.../build/Release/addon.node
Reason: image not found
(sorry if this has been solved somewhere, i've looked at everything I could find, however I could of missed something, it's 3:30 AM right now as I type this 😅 )
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
No repository file or test is named. Start with the provided target configuration and the macOS dlopen error, then inspect how node-gyp passes the library and linker settings to the addon. Done means identifying the runtime library-resolution issue and documenting the supported configuration or required change.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp, electron, macos, node.js, python
- Domain
- build-system, devtools
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100