Comments (10)
Try setting LD_LIBRARY_PATH
to the absolute path to the directory that contains your dylib.
from evcxr.
Try setting
LD_LIBRARY_PATH
to the absolute path to the directory that contains your dylib.
Thanks for your help, I just tried what you said and got the same error.
When I use the function adding_from_Library
in another program with command cargo run
, the function works fine. But it doesn't work in notebook. I think it might be related to the method cargo_command
from eval_context.rs
. The generated command may lose something so the compiler cannot find the library.
from evcxr.
Does it work if you use
:env LD_LIBRARY_PATH=/path/to/dynlink/library
:restart
?
from evcxr.
Does it work if you use
:env LD_LIBRARY_PATH=/path/to/dynlink/library :restart
?
I just tried what you said, and still got the same error.
Then I copied the libawesome_math.so
file to the directory path_to_tmpdir\target\x86_64-unknown-linux-gnu\debug\deps
, and still got the same error. I'm curious why this error happen, doesn't the compiler find the shared object in this directory. If it does, why the compiler cannot find the shared object?
from evcxr.
The error happens after compilation. It happens when evcxr attempts to dlopen the dylib is compiled for the user code. It finds the dylib, but then the dynamic linker doesn't find where libawesome_math.so
is. Setting LD_LIBRARY_PATH
should tell the dynamic linker in which directory it can find it, but for some reason that doesn't help for you.
from evcxr.
The error happens after compilation. It happens when evcxr attempts to dlopen the dylib is compiled for the user code. It finds the dylib, but then the dynamic linker doesn't find where
libawesome_math.so
is. SettingLD_LIBRARY_PATH
should tell the dynamic linker in which directory it can find it, but for some reason that doesn't help for you.
Is there way that I copy the libawesome_math.so
file to a specific location, so that the compiler can find it?
from evcxr.
The dynamic linker should look in /lib
, /usr/lib
, /usr/local/lib
(only writable as root and I strongly recommend not to add any files here, but if you do anyway prefer /usr/local/lib
. that one is not under the control of your distro's package manager) and all the directories mentioned by LD_LIBRARY_PATH
. Can you check if println!("{:?}", std::env::var("LD_LIBRARY_PATH"));
does mention the LD_LIBRARY_PATH
you tried to set?
from evcxr.
The dynamic linker should look in
/lib
,/usr/lib
,/usr/local/lib
(only writable as root and I strongly recommend not to add any files here, but if you do anyway prefer/usr/local/lib
. that one is not under the control of your distro's package manager) and all the directories mentioned byLD_LIBRARY_PATH
. Can you check ifprintln!("{:?}", std::env::var("LD_LIBRARY_PATH"));
does mention theLD_LIBRARY_PATH
you tried to set?
When I run this cell in notebook:
std::env::var("LD_LIBRARY_PATH")
//output: Ok("/root/dynlink/library")
I put the libawesome_math.so
in /usr/lib
, and deleted the build.rs
file. Then I cd
into directory dynlink/executable
and ran cargo run
, and got this error:
/root/dynlink/executable/src/lib.rs:7: undefined reference to `from_the_library'
It seems the putting the .so
file in /usr/lib
doesn't work on my computer.
from evcxr.
I tried creating a directory structure like you said and I got a different error. For me the error wasn't that it couldn't find the .so file, it was that it couldn't find the symbol. I'm not sure what you were doing to get it to try to load the .so file. I got it to load it by adding #[link(name = "awesome_math")]
before extern
in lib.rs.
I've attached a .tar.gz of the directory structure that worked for me. I didn't use LD_LIBRARY_PATH, but instead set rpath
like you were doing in one of your earlier attempts.
from evcxr.
❯ ~/work/evcxr/target/debug/evcxr
Welcome to evcxr. For help, type :help
>> :dep executable = { path = "executable" }
Compiling libc v0.2.151
Compiling cc v1.0.83
Compiling executable v0.1.0 (/home/david/tmp/358/executable)
>> executable::adding_from_library()
()
Adding: 3
from evcxr.
Related Issues (20)
- how to trigger code auto completion HOT 2
- Can't use tch-rs in Jupyter Hub HOT 3
- Can't use tch-rs in Jupyter Hub (Part 2) HOT 3
- Can't use Burn (MNIST example) HOT 6
- Race condition between idle and iopub messages in `evcxr_jupyter`? HOT 4
- Invalid code generation when no tokio dependency is added HOT 2
- Invalid code generation when using the question mark operator directly after `.await` HOT 1
- Trying to include a local package gives a manifest error HOT 7
- How can I reuse a target directory from a workspace? HOT 2
- How to add :cache 500 to my ~/.config/evcxr/init.evcxr HOT 3
- shell command in evcxr jupyter HOT 1
- unresolved import `core::unicode` HOT 10
- evcxr works with atom/pulsar hydrogen HOT 2
- Errors not shown HOT 2
- Cargo patch dependency issue HOT 5
- cannot assign a variable to a const/static variable HOT 1
- Problem converting a Vec to a &[] struct HOT 2
- Tab completion on Vectors not working HOT 1
- Autocomplete for :doc does not work
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from evcxr.