I’m a newbie trying to compile a fairly complicated code under Fedora Core 3 using pgi 6.0-2 set of compilers. Part of the code was compiled with gcc, and part with pgf90. At first all compiling went smoothly, but then the linking with pgf90 did not pass:
/usr/pgi/linux86/6.0/bin/pgf90 -g77libs <many object files> -L/MODIS/Mapi/STORE/shared_lib/mapi/mapi2.3.4/lib -lmapi -L/MODIS/TOOLKIT/lib/linux -lPGSTK -lm -L/MODIS/TOOLKIT/hdfeos/lib/linux -lhdfeos -L/MODIS/TOOLKIT/hdf5/linux/hdf5-1.6.4/lib -lhdf5shared -L/MODIS/TOOLKIT/hdf/linux/HDF4.2r1/lib -lmfhdf -ldf -ljpeg -lz -o MOD_PR04_05.exe -v /usr/bin/ld /usr/lib/crt1.o /usr/lib/crti.o /usr/lib/gcc/i386-redhat-linux/3.4.3/crtbegin.o /usr/pgi/linux86/6.0/lib/f90main.o -m elf_i386 -dynamic-linker /lib/ld-linux.so.2 <many object files> -L/MODIS/Mapi/STORE/shared_lib/mapi/mapi2.3.4/lib -L/MODIS/TOOLKIT/lib/linux -L/MODIS/TOOLKIT/hdfeos/lib/linux -L/MODIS/TOOLKIT/hdf5/linux/hdf5-1.6.4/lib -L/MODIS/TOOLKIT/hdf/linux/HDF4.2r1/lib -L/usr/pgi/linux86/6.0/lib -L/usr/lib -L/usr/lib/gcc/i386-redhat-linux/3.4.3 -L/usr/lib/gcc/i386-redhat-linux/3.4.3 -rpath /usr/pgi/linux86/6.0/lib -lmapi -lPGSTK -lm -lhdfeos -lhdf5shared -lmfhdf -ldf -ljpeg -lz -lpgf90 -lpgf90_rpm1 -lpgf902 -lpgf90rtl -lpgftnrtl -lg2c -lc -lnspgc -lpgc -lm -lgcc -lc -lgcc /usr/lib/gcc/i386-redhat-linux/3.4.3/crtend.o /usr/lib/crtn.o /usr/pgi/linux86/6.0/lib/f90main.o(.text+0x77): In function `main': : undefined reference to `MAIN_' MOD_PR04_PR05_V2.o(.text+0x1b3): In function `MAIN__': : undefined reference to `pgs_pc_getreference__' MOD_PR04_PR05_V2.o(.text+0x21b): In function `MAIN__': : undefined reference to `pgs_pc_getreference__' MOD_PR04_PR05_V2.o(.text+0x909): In function `MAIN__': : undefined reference to `pgs_met_getpcattr_s__' <many other undefined references>
I did manage to get rid of the several undefined references in the end. They were the consequence of a second underscore added by gcc during compiling, so I recompiled the object files with a -fno-second-underscore flag. Then only the first undefined reference remained:
/usr/pgi/linux86/6.0/lib/f90main.o(.text+0x77): In function `main': : undefined reference to `MAIN_'
Searching this forum, I believe I found a solution to this issue by adding -Mnomain just after -g77libs in the linking line. But then I get another error:
/usr/lib/crt1.o(.text+0x18): In function `_start': : undefined reference to `main' pgf90-Fatal-linker completed with exit code 1
I have some questions, maybe a little too simplistic for this forum, but anyway:
is it ok to have these errors pointing only to “system” files? I mean, after I solved the issue with the files in the code I am compiling, I find a bit odd to have the compiler complaining about the f90main.o and crt1.o files…
is it ok to solve the “undefined reference to `MAIN_’” issue by using that -Mnomain flag? Isn’t it going to cause other problems ahead like the problem in (3)?
any ideas on how to solve the last "undefined reference to `main’ in file crt1.o?
Any inputs on these issues would be really appreciated.