I am trying to compile my code with with the g77 compiler while linking with a library file that was previously compiled with pgf77. I have heard about the extra underscore problem but when I tried the -Msecond_underscore flag, it didn’t work so I am certain I am not doing something right. Any help would be greatly appreciated.
You can just compile as normal. For example:-
I have 2 files:
myhost% cat a.f
myhost% cat main.f
print *, “C is”, c
myhost% g77 a.f -c
myhost% pgf77 a.o main.f
C is 4
As long as you link to the right libraries.
Thanks Hongyoon for your post but I am not sure that it has addressed the crux of my problem.
Say I have a library called libutil.a which was compiled using pgf77 and now it’s to be used on a computer running g77 and on which it would be inconvenient to install pgf77. I am thus constrained to using g77. When I typed g77 main.f libutil.a, most of the files containing subroutines in libutil.a couldn’t be found. So I thought it might be because g77 introduces the extra underscore. Of course, this hunch might be wrong. I hope you or anyone else can better direct me.
Thanks a great deal once again.
I suspect that it can’t find some PGI runtime libraries that libutil.a needs. You will need to make sure that you link to PGI libraries. I am not sure which ones it needs. You can look on a system that you have PGI compilers and link and add -v in the options and it should display a list of libraries that it link against on the link line. For example, pgf77 main.f libutil.a -v