Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.

Linking C static library to IVF

mhovers
Beginner
444 Views

I have an IVF project where one f90 subroutine calls a C subroutine as:

! For SuperLU, use the previously stored matrix factorization from the

! primal problem.

!

call c_fortran_zgssv_( 2, 2*nnod, nnz, 1, val,col,irw, &

& ewt, 2*nnod, factors, info )

I have created a static library containing

void

c_fortran_zgssv_(int *iopt, int *n, int *nnz, int *nrhs,

doublecomplex *values, int *rowind, int *colptr,

doublecomplex *b, int *ldb,

fptr *f_factors, /* a handle containing the address

pointing to the factored matrices */

int *info)

in C:mhoversmare2d_v2SuperLU_3.0Fortran_linkReleaseFortran_link.lib

In my IVF Project Properties -> Linker -> General->Additional Library Directories I have the path to the *.lib files

C:mhoversmare2d_v2SuperLU_3.0Fortran_linkRelease

In Tools->Options->Intel Fortran ->General -> Libraries I have:

C:mhoversmare2d_v2SuperLU_3.0Fortran_linkRelease (in addition to all the default stuff)

I have also played with adding/subtracting _ before and after the routine name but no mater what I get error LINK2019: unresolved external symbol _C_FORTRAN_ZGSSV

Is there somewhere else I need to tell it to find the *.lib or somewhere I have to explicitly name the Fortran_link.lib that contains the C object??

Thanks,

0 Kudos
2 Replies
Steven_L_Intel1
Employee
444 Views
Linker > Input > Additional Dependencies
or
add a !DEC$ OPTIONS LIB:'Fortran_link.lib' to one of the sources
or
add the .lib to the project as if it were a source file
0 Kudos
TimP
Honored Contributor III
444 Views
In addition, the linkage names must be made to agree in case as well as underscoring. A Fortran C interoperability interface block is the most portable way to accomplish this. Prior to introduction of C interop, a relatively ugly way was to compile the C code with e.g. -Dlowercasename_=UPPERCASENAME . I can think of at least 2 additional ways
Several equivalent tools can be used to examine the C and Fortran .obj files to check that the linkage names match.
0 Kudos
Reply