undefined reference

Hi!

I am compiling some Fortran and C code on Linux, but I am unable to solve the linking problem :

[make: Warning: File REGRID_to_v5d.f.m' has modification time 1.6e+03 s in the future pgf77 REGRID_to_v5d.o binio.o v5d.o -lm -o REGRID_to_v5d REGRID_to_v5d.o: In function MAIN_’:
REGRID_to_v5d.f:(.text+0x37): undefined reference to pghpf_init' REGRID_to_v5d.f:(.text+0x93): undefined reference to pgf90io_src_info’
REGRID_to_v5d.f:(.text+0xb6): undefined reference to pgf90io_ldw_init' REGRID_to_v5d.f:(.text+0xe9): undefined reference to pgf90io_ldw’
REGRID_to_v5d.f:(.text+0xf0): undefined reference to pgf90io_ldw_end' REGRID_to_v5d.f:(.text+0xff): undefined reference to pgf90_exit’
REGRID_to_v5d.f:(.text+0x120): undefined reference to pgf90io_src_info' REGRID_to_v5d.f:(.text+0x143): undefined reference to pgf90io_ldw_init’
REGRID_to_v5d.f:(.text+0x14a): undefined reference to pgf90io_ldw_end' REGRID_to_v5d.f:(.text+0x16b): undefined reference to pgf90io_src_info’
REGRID_to_v5d.f:(.text+0x189): undefined reference to pgf90io_ldw_init' REGRID_to_v5d.f:(.text+0x190): undefined reference to pgf90io_ldw_end’
REGRID_to_v5d.f:(.text+0x1b1): undefined reference to pgf90io_src_info' REGRID_to_v5d.f:(.text+0x1ea): undefined reference to pgf90io_fmtw_init’
REGRID_to_v5d.f:(.text+0x21d): undefined reference to pgf90io_fmt_write' REGRID_to_v5d.f:(.text+0x22d): undefined reference to .BSS1’
REGRID_to_v5d.f:(.text+0x24b): undefined reference to pgf90io_fmt_write' REGRID_to_v5d.f:(.text+0x252): undefined reference to pgf90io_fmtw_end’
REGRID_to_v5d.f:(.text+0x273): undefined reference to pgf90io_src_info' REGRID_to_v5d.f:(.text+0x2b1): undefined reference to pgf90io_fmtw_init’]
etc…

My main program is written in Fortran, but uses calls to getarg, and my makefile looks like:
[CFLAGS = -c -g -DUNDERSCORE -DLITTLE
FFLAGS = -c -g -byteswapio
CC = cc
F77 = pgf77
LIBS=-lm

OBJECTS = $(PROGRAM).o binio.o v5d.o

$(PROGRAM): $(OBJECTS)
$(F77) $(OBJECTS) $(LIBS) -o $@

$(PROGRAM).o: $(PROGRAM).f
$(F77) $(FFLAGS) -I/usr/local/vis5d/src $(PROGRAM).f

binio.o: /usr/local/vis5d/src/binio.c
$(CC) $(CFLAGS) /usr/local/vis5d/src/binio.c -o binio.o

v5d.o: /usr/local/vis5d/src/v5d.c
$(CC) $(CFLAGS) /usr/local/vis5d/src/v5d.c -o v5d.o ]

The same error is present if I use pgf90 too. I am using Suse 10.0 : Linux 2.6.13-15-bigsmp #1 SMP Tue Sep 13 14:56:15 UTC 2005 i686 i686 i386 GNU/Linux. However, I was able to make an executable on some older Linux version: Linux 2.4.22-1.2115.nptl #1 Wed Oct 29 15:42:51 EST 2003 i686 i686 i386 GNU/Linux.

I would appreciate any help !

Regards,
Kristian

Hi Kristin,

Since your makefile uses pgf77, but the undefined references were to pgf90 runtime symbols, I’m guessing that the objects were built with an earlier version of the pgf90 compiler. While you do still get undefined references when linking with the latest version of pgf90, do some of them disappear? Can you try making sure the the object files are removed and then rebuilding?

Hope this helps,
Mat

Hi Mat,

thanks for trying to help. I removed all the object files and compiled with pgf90. Here is the output:

make: Warning: File `REGRID_to_v5d.f.m' has modification time 1.1e+03 s in the future
pgf90 -c -g -byteswapio -I/usr/local/vis5d/src REGRID_to_v5d.f
PGF90-W-0119-Redundant specification for ilev (REGRID_to_v5d.f: 69)
  0 inform,   1 warnings,   0 severes, 0 fatal for regrid_to_v5d
/tmp/pgf90Iun28R.s: Assembler messages:
/tmp/pgf90Iun28R.s:11602: Warning: size (-2109276808) out of range, ignored
cc -c -g -DUNDERSCORE -DLITTLE /usr/local/vis5d/src/binio.c -o binio.o
cc -c -g -DUNDERSCORE -DLITTLE /usr/local/vis5d/src/v5d.c -o v5d.o
pgf90 REGRID_to_v5d.o binio.o v5d.o -lm -o REGRID_to_v5d
REGRID_to_v5d.o: In function `regrid_to_v5d':
/Network/Servers/xserve.meso.ncsu.edu/Volumes/vol2/home/kristian/mm5/VIS5d/REGRID_to_v5d/REGRID_to_v5d.f:109: undefined reference to `.BSS1'
/Network/Servers/xserve.meso.ncsu.edu/Volumes/vol2/home/kristian/mm5/VIS5d/REGRID_to_v5d/REGRID_to_v5d.f:110: undefined reference to `.BSS1'
/Network/Servers/xserve.meso.ncsu.edu/Volumes/vol2/home/kristian/mm5/VIS5d/REGRID_to_v5d/REGRID_to_v5d.f:114: undefined reference to `.BSS1'
/Network/Servers/xserve.meso.ncsu.edu/Volumes/vol2/home/kristian/mm5/VIS5d/REGRID_to_v5d/REGRID_to_v5d.f:115: undefined reference to `.BSS1'
/Network/Servers/xserve.meso.ncsu.edu/Volumes/vol2/home/kristian/mm5/VIS5d/REGRID_to_v5d/REGRID_to_v5d.f:120: undefined reference to `.BSS1'
REGRID_to_v5d.o:/Network/Servers/xserve.meso.ncsu.edu/Volumes/vol2/home/kristian/mm5/VIS5d/REGRID_to_v5d/REGRID_to_v5d.f:124: more undefined references to `.BSS1' follow
make: *** [REGRID_to_v5d] Error 2

Here is the part of the code referenced:

    103 C GET COMMAND LINE ARGUMENTS
    104 c          ab=2
    105        If (iargc() .ne. 2) then
    106           Print *,'Error:  two filename arguments are needed.'
    107           Call Exit(1)
    108        Else
    109           Call GetArg(1, parsREGRIDname)
    110           Call GetArg(2, v5dname)
    111        Endif
    112        Print *
    113        Print *
    114        Print 10,'Input file (pars REGRID): ', parsREGRIDname
    115        Print 10,'Output file (V5D): ', v5dname
    116 10     Format (A,A)

so I thought that it has problems with linking C built-in libraries. But then I declared variable ab and set ab=2, after linking there is “undefined reference” to that line too:

REGRID_to_v5d.o: In function `regrid_to_v5d':
/Network/Servers/xserve.meso.ncsu.edu/Volumes/vol2/home/kristian/mm5/VIS5d/REGRID_to_v5d/REGRID_to_v5d.f:104: undefined reference to `.BSS1'
/Network/Servers/xserve.meso.ncsu.edu/Volumes/vol2/home/kristian/mm5/VIS5d/REGRID_to_v5d/REGRID_to_v5d.f:109: undefined reference to `.BSS1'
/Network/Servers/xserve.meso.ncsu.edu/Volumes/vol2/home/kristian/mm5/VIS5d/REGRID_to_v5d/REGRID_to_v5d.f:110: undefined reference to `.BSS1'
/Network/Servers/xserve.meso.ncsu.edu/Volumes/vol2/home/kristian/mm5/VIS5d/REGRID_to_v5d/REGRID_to_v5d.f:114: undefined reference to `.BSS1'
/Network/Servers/xserve.meso.ncsu.edu/Volumes/vol2/home/kristian/mm5/VIS5d/REGRID_to_v5d/REGRID_to_v5d.f:115: undefined reference to `.BSS1'
REGRID_to_v5d.o:/Network/Servers/xserve.meso.ncsu.edu/Volumes/vol2/home/kristian/mm5/VIS5d/REGRID_to_v5d/REGRID_to_v5d.f:120: more undefined references to `.BSS1' follow
make: *** [REGRID_to_v5d] Error 2

The preblem is the same whether using pgf77 or pgf90. I just cant figure out what is wrong.

Kristian

Hi Kristin,

The pgf90 unresolved symbol names were caused because the Fortan source files were compiled with pgf90, but you were linking with pgf77. To link pgf90 compiled code with pgf77 or pgcc, please add “-pgf90libs” to the link line so that the pgf90 runtime libraries are used. A second flag, “-pgf77libs” adds the runtime libraries for pgf77 compiled code.

As fo the “.BSS” undefined references, I’m not entirely sure what’s causing these. I went ahead and downloaded “vis5d+” from Sourceforge and found REGRID_to_v5d HERE. However when I tried it, the program compiled and linked correctly on SuSE10.

I wondering if your using an older compiler? The GNU binutils, including the ld linker, underwent some major changes with SuSE10 and the PGI compiler support for SuSE10 was not available until the 6.0-8 release (Please refer to our supported release information page). If this is the case, then you’ll need to upgrade the compilers in order to use them on SuSE10.

  • Mat

Hello Mat,

thanks for tips, I had the older version of PGI compiler, so I decited to compile my program on other machine and it worked well.

bye,
Kristian