Closed ra0x3 closed 1 year ago
Rust does not export functions by default (you need to make them public!) and it also mangles functions by default (see the no_mangle
attribute – documentation references this problem here). You’re also missing extern
for your function definition to make sure that the ABI matches on both sides. This chapter from nomicon might be helpful to you.
libfoo.dylib
suggests me you’re on MacOS. You should be able to use the nm
utility to list the symbols in your library. For a symbol to be importable, it’ll need to have a capital letter (indicating it is an exported global symbol) such as T
on the 2nd column.
I strongly recommend seeking advice/help on the venues dedicated to helping Rustaceans – you will be able to get help much faster than from me on this issue tracker.
Description
Error
Minimum reproducible example
Project layout
My fake library who's function I'd like to call
My fake binary, in which I'm trying to load my
foo
library and call it'sfoobar
functionExpected behavior
foobar
function infoo/src/lib.rs
to get called, thus printing"Hello world!"