Problems calling Fortran library from C (and Fortran)

Problems calling Fortran library from C (and Fortran)

I have a very old library that I don't have its source code. This library was written in FORTRAN and it was compiled using Open Watcom (OW) compiler.

I am trying to port it to Intel and I did the following steps:

1) At first, I tried to link it directly using Intel and I got the following messages:

ipo: warning #11010: file format not recognized for oldlibrary.lib...oldlibrary.lib: fatal error LNK1136: invalid or corrupt file

2) Then, I used a library utility that comes with OW called wlib to convert the library to AR format. Indeed, I don't  know if this works, but I have other library compiled against OW that I converted to AR format and is working pretty well in other project compiled with Intel.

3) Now, in fact, Intel seems to accept the library format, but it comes up with the following naming convention errors:

mysubroutine.obj: error LNK2019: unresolved external symbol _OLDLIBRARYROUTINE1 referenced in function _MYFUNCTIONmysubroutine.obj: error LNK2019: unresolved external symbol _OLDLIBRARYROUTINE2 referenced in function _MYFUNCTION...

If I check the names inside the library, none of them are defined with prepended underscores.

Is there a manner to indicate to Intel Fortran linker that it should not prepend underscores to these subroutine names (OLDLIBRARYROUTINE1, OLDLIBRARYROUTINE2, etc...)?

Thanks in advance,

Regards

publicaciones de 5 / 0 nuevos
Último envío
Para obtener más información sobre las optimizaciones del compilador, consulte el aviso sobre la optimización.

Even if you overcome the minor problem with leading underscores appended to external names, there are two more inconsistencies that you are going to have to deal with.

The register-level calling conventions between Intel and OWC may not be compatible.

The library that you have will have dependencies on the OWC Fortran runtime that you will have to resolve. If there are any such routines that are also present in the Intel Fortran runtime the problem will be even more difficult to solve.

Have you considered compiling your driver with OWC (available as a free download) instead, so that all these problems may be avoided?

Hi mecej4,

I appreciate your answer, thanks.

I confess that I wasn't aware of the problems regarding compatibility you mentioned. However, I do have other project in which I successfully link-edited a library compiled in OWC with a program compiled in Intel Fortran. Maybe its a matter of luck, but it is working without problems so far.

If there is a way to simply indicate to Intel Fortran that it should not prepend underscores to these names, I would like to give it a try. Do you know if is there such way and how to do it?

Regarding compiling my program with OWC, indeed nowadays I can compile my program both using OWC (first version) and Intel Compiler (latter version) but, under Intel Compiler, this library is disabled. I would like to completely port the whole application to Intel Compiler, including this library and then move on using Intel Compiler exclusively.

Successful compilation does not imply successful linking. Successful linking does not imply successful running. Unless you ensure for yourself that the OWC-compatible custom library is also compatible with IFort-compiled code, and this requires an understanding of calling conventions at the assembler level, you should not think that a compiled and linked EXE will also run correctly.

This other project I am talking about that is compiled/linked with Intel Fortran and uses a library compiled in OWC is RUNNING successfully on a daily basis in my company.

I was hoping to get the same thing once I overcome the naming problems with the prepended underscores.

Deje un comentario

Por favor inicie sesión para agregar un comentario. ¿No es socio? Únase ya