I used the Rust installer from rust-lang.org.
rustc --version gives:
rustc 1.2.0 (082e47636 2015-08-03)
I'm following the "Rust Inside Other Languages" instructions located here:
http://doc.rust-lang.org/book/rust-inside-other-languages.html
I use the Rust code provided, then alter it to have the no_mangle attribute and pub extern keywords in front of the process function.
I also add the [lib] section to my Cargo.toml file and can tell that it works because it outputs embed.dll instead of libembed.rlib.
I'm running:
cargo build --release
When I use the python code to call into embed.dll I get this error:
Traceback (most recent call last):
File "embed.py", line 3, in
lib = cdll.LoadLibrary("target/release/embed.dll")
File "c:\Python27\lib\ctypes_init_.py", line 431, in LoadLibrary
return self.dlltype(name)
File "c:\Python27\lib\ctypes_init.py", line 353, in init
self._handle = _dlopen(self._name, mode)
WindowsError: [Error 193] %1 is not a valid Win32 application
Note that I did replace:
lib = cdll.LoadLibrary("target/release/libembed.so")
with:
lib = cdll.LoadLibrary("target/release/embed.dll")
I have also tried calling into it from C# with this PInvoke setup:
[DllImport("embed.dll", CallingConvention = CallingConvention.Cdecl)]
static extern void process();
And I get this error:
System.BadImageFormatException: An attempt was made to load a program with an incorrect format. (Exception from HRESULT: 0x8007000B)
at RustSpeedTest.Program.process()
snip
Is this working on windows for others?