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

Linking old libraries...

teclis77
Beginner
623 Views
Hi,
first of all, I use Visual Fortran 9.0 in the enviroment Visual C++ .NET (2003).

I have a big problem when I link a dynamic library made with Visual C++ 6.0.
My code has to link two libraries: one of these is the Cern Libraries (these are "static Libraries"). I found a version for Visual Fortran Intel 8.0 (the results and the projects with the source codes). I tried to rebuild, but I'm not able (I don't know why, maybe because the Cern Projects contains different projects...)
The second library is JAPI (Java interface for Fortran, C++ and so on...). This library is a dynamic library and I have the source code (open-source). The code is in C language and linked, as I have just said, with Visual C++ 6.0.

Now, I found a problem with the "calling convention" (see for example http://groups.google.it/group/comp.lang.fortran/browse_thread/thread/289d2ef48b5e7d81/5248db3d8ea7f54c?lnk=st&q=&rnum=1&hl=it#5248db3d8ea7f54c), i.e. the external symbols exported are (for example) _J_START@0, not _J_START. This is what CVF would have been looking for by default which is why you were OK with CVF. Intel isn't looking for the same, because default calling convention changed in the meantime from stdcall/len_after_string_arg to cdecl/len_at_the_arglist_end.

One solution is to
change "Calling convention" Project Properties/Fortran/External Procedure from "Default" to "CVF" and chose "After All Arguments".

With this procedure all is right and Japi works well (I would like to thanks Jugoslav...)...

BUT when I link also the Cern Lib, I found the problem in the reverse mode, i.e. the calling convention is not right!

I tried to make a static library (made in "CVF" mode), where I build the interface - in this way I am sure that all the calls are resolved... - and include it in my project (in "default" mode), but I have obviously some linking problems...

How I can resolve my big problem?

Teclis
0 Kudos
2 Replies
Steven_L_Intel1
Employee
623 Views

Does this JAPI library come in a version that uses C calling conventions? This would be for use with C and Fortran compilers other than CVF and MS FPS. If it does, use that. Perhaps there is a define in the C code used to establish the calling convention that you can change - I have seen that in some libraries.

The other approach is to write a module that contains interface blocks for the JAPI calls you use, including appropriate !DEC$ ATTRIBUTE lines. For example:

interface
subroutine J_START
!DEC$ ATTRIBUTES STDCALL,REFERENCE,MIXED_STR_LEN_ARG,DECORATE,ALIAS:"J_START" :: J_START
end subroutine J_START
end interface
...
0 Kudos
teclis77
Beginner
623 Views
Ok,
we substituted in the source code of Japi libraries
Old: __stdcall
New: __cdecl

and now everityng is working (more or less...)

Thank you very much

Teclis

0 Kudos
Reply