Anand, Vaidyanathan R wrote:
> I have a Fortran program that I am trying to link with static libraries
> that have been created with Visual C (static libraries only, .lib files;
> no DLL). Supposedly one should be able to link with these on the gcc/g77
> command line by naming the .lib files directly after the source.
I thought the object-file formats were incompatible, so that this
would not be possible. But I'd like to know if I got that wrong.
> 3. Is the above failure due to differences in name-mangling between VC
> and gcc;
If names differ due to mangling, then the difference in name
mangling is a safeguard to protect against even worse problems.
Here's my attempt to explain why:
> I have also tried g77 with and without the -fno-underscoring flag
Usually 'mangling' means getting a weird long name for a C++
function. Is that what's happening, or is it just a matter of
adding or removing an underscore?
> if so, is there a way around it ?
Yes. You're on the right track with your next question:
> 4. Failing all the above, is it possible to convert the static libraries
> to a DLL and then link with gcc/g77 in the usual way after creating an
> import library ?
Compile everything with gcc if you can. If you have to use a
library for which you don't have the source, try wrapping the
static library in a DLL built with msvc, expose a C interface
(with 'extern "C"' if the code is C++), and link your gcc
application to that DLL.