Segmentation fault directly running a lib.so


#1

Running the example lib [ libembed.so ] from https://doc.rust-lang.org/stable/book/rust-inside-other-languages.html via command line in the way I would a program, gives a simple ‘Segmentation fault’ error.

I wonder is not exactly as that should be; I was expecting it to either suggest that lib.so are unavailable as normal programs in their own right… or that it would run in some graceful incomplete way.

No pun intended but my programming skills are rusty; so, I don’t know if libraries are always simple standard reference programs just cast as lib or properly a different category.


#2

Yeah, libraries aren’t executables, so you shouldn’t be able to run it. What exactly did you type in, and what platform are you on?


#3

Linux Mint 17.0

cd ~/projects/embed/ ./target/debug/libembed.so


#4

Actually, they are (at least on linux): https://serverfault.com/questions/173853/why-shared-libraries-on-linux-are-executable. TIL…


#5

Incidentally, the reason I was trying that followed from the exercise talking of use of Ruby and Python etc to action that library; and talk of gem rather than apt-get, didn’t make it easier making another problem for that simple action of the library.

Better perhaps to illustrate a call from another Rust program?.. I expect there are enough instances I’ll find one later but my attempt at it, didn’t work immediately… lots to learn.


#6

action

I assume you mean execute. This section isn’t about executing a library itself, it’s about calling individual functions defined inside of the library.

Better perhaps to illustrate a call from another Rust program?

This section is about calling rust functions from other languages, not rust from rust. Also, the sections immediately following the one you linked explain how to use libembed.so from other languages.