Hello everybody
I just signed up for help. Really I can't.
I am on Windows 10, MSVC and Intel Fortran 9.0
My first idea was to test LAPACK (with crate LAPACK). No success.
Now I am trying a very small problem. Still without success.
So I'm looking for a little example that really works.
For example with a Fortran LIB with code
opmath2.for
integer(c_int) function double_input (input) BIND (C)
use iso_c_binding
implicit none
integer(c_int), VALUE :: input
integer(c_int) double_input
double_input = 2 * input
end function
with main.rs
# [link (name = "opmath2")]
extern "C" {
pub fn double_input (val: i32) -> i32;
}
fn main () {
let v = 3;
let _w = unsafe {double_input (v)};
}
Can someone give me a working example? Or a corresponding website.
Thanks
my LIB content
dumpbin /symbols /exports opmath2.lib
Microsoft (R) COFF/PE Dumper Version 9.00.21022.08
Copyright (C) Microsoft Corporation. All rights reserved.
Dump of file opmath2.lib
File Type: LIBRARY
COFF SYMBOL TABLE
000 00000000 DEBUG notype Filename | .file
opmath2.f90
002 00000000 SECT1 notype Static | .drectve
Section length D3, #relocs 0, #linenums 0, checksum 0
004 00000000 SECT2 notype Static | .text
Section length 10, #relocs 0, #linenums 0, checksum 0
006 00000000 SECT2 notype () External | double_input
007 00000000 UNDEF notype () External | __ImageBase
run with cargo
cargo build
Compiling mystatic v0.1.0 (C:\Users\Gilles\Documents\Projets\Rust\mystatic)
Finished dev [unoptimized + debuginfo] target(s) in 2.67s
cargo run
Finished dev [unoptimized + debuginfo] target(s) in 0.05s
Running `C:\Users\Gilles\Documents\Projets\Rust\mystatic\target\debug\mystatic.exe`
error: process didn't exit successfully: `C:\Users\Gilles\Documents\Projets\Rust\mystatic\target\debug\mystatic.exe` (exit code: 0xc0000005, STATUS_ACCESS_VIOLATION)
** AFTER ONE WEEK **
I ended up making myself a little C++ example called Fortran.
I had to do: (MSVC)
cl myCode.cpp myFortran.lib A.lib B.lib C.lib
where library A, B and C are Fortran lib.
If I look output of
cargo build I see
> .....
> ..... link.exe ... "/LIBPATH ....."/WHOLEARCHIVE:myFortran.lib"
> .....
How do I add A.lib B.lib and C.lib?
I have main.rs:
**main.rs**
> # [link (name = "myFortran")]
> extern "C" {
> pub fn double_input (val: i32) -> i32;
> }
>
> fn main () {
>
> let v = 3;
> let _w = unsafe {double_input (v)};
>
> }