- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I try to link an old Fortran legacy code with a C++ library, developed for CVF6.6. Using the mixed language sample to call C++ library from Fortran, I modified the interface declaration, but I could not resolve the LNK2019 error. I attach the Fortran source, the lib and dll file obtained as part of the Poisson Superfish package.
Unfortunately I do not have the source code for the C++ library. Any help would be appreciated to resolve the problem.
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
It always helps, when asking for help on an error, to show the exact and complete text of the error, rather than just referring to it by number. None of us have memorized all the error numbers, and LNK2019 is extremely generic.
The library assumes CVF calling convention, which is STDCALL. The simplest way to deal with this is to add the line:
!DEC$ ATTRIBUTES CVF :: INTERP
after the IMPORT line in your interface for INTERP. (I assume you are using a reasonably current version of Intel Fortran. If you're using one from 2011 or so, I don't want to hear about it.)
If this doesn't resolve the issue, please ZIP the buildlog.htm and attach that to a reply here.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I forget to add, that inserting the
!DEC$ ATTRIBUTES CVF :: INTERP
did not solve the problem.
Tibor
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Oh, I missed that you had BIND(C) at the end of the declaration of INTERP. Try this:
Interface Integer(kind=4) function INTERP(SolutionFile, Xvalue, Yvalue, Solution, Xcomponent, Ycomponent, DBYDY, DBYDX, DBXDY) bind(C,NAME="INTERP") IMPORT ! Use declarations from host !DEC$ ATTRIBUTES STDCALL :: INTERP CHARACTER(kind=C_CHAR), Dimension(*), Intent(IN) :: SolutionFile Real (kind=8), Intent(IN) :: Xvalue, Yvalue Real (Kind=8), Intent(OUT) :: Solution, Xcomponent, Ycomponent Real (Kind=8), Intent(OUT) :: DBYDY, DBYDX, DBXDY End Function INTERP End Interface
This should link, but I note that your program doesn't NUL-terminate SolutionFile and the library is not expecting a length to be passed (9 arguments at 4 bytes each corresponds to the @36 suffix), so I am not sure how it determines the character length.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
tkibedi wrote:I forget to add, that inserting the
!DEC$ ATTRIBUTES CVF :: INTERP
did not solve the problem.
Tibor
Once you get past the linking error, you can take a closer look at your code: did you mean to declare the 'SolutionFile' as a scalar variable in line 17 with a default length which is 1?
By the way, from a portability viewpoint for interoperable code, you may want to use the defined kinds in 'ISO_C_BINDING' intrinsic module of c_int and c_double rather than hard-wired ones of 4, 8 which don't have the same meaning on different compilers. Also, you may want to consider the BLOCK with EXIT construct (https://software.intel.com/en-us/fortran-compiler-developer-guide-and-reference-block) which is preferable to DO intended to used as one-pass.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page