I have a project with two files:
rle.rs contains the following (and much more):
extern crate libc;
pub struct Rle {
pub lengths: Vec<i32>,
pub values: Vec<i32>,
}
pub extern "C" fn rle_new(blablabla...)
lib.rs as follows:
mod rle;
use rle::rle_new;
When I load the library in Python, I get the error:
Traceback (most recent call last):
File "compact_ranges.py", line 19, in <module>
lib.rle_new.restype = POINTER(RleS)
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/ctypes/__init__.py", line 378, in __getattr__
func = self.__getitem__(name)
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/ctypes/__init__.py", line 383, in __getitem__
func = self._FuncPtr((name_or_ordinal, self))
AttributeError: dlsym(0x7f94ca700370, rle_new): symbol not found
It seems that Rust understands this (smart, smart) because my linter says:
17 1 warning function rle_new is marked #[no_mangle], but not exported, #[warn(private_no_mangle_fns)] on by default (rust-cargo)
How to fix this and make my function rle_newaccessible from target / debug / libranges.dylib?
crate-type > ["dylib"]
source
share