linuxcompiler-errorsscons

Undefined reference to xdr_float,...,etc


Having trouble linking to the 'rpc' library. My system is OpenSUSE Leap 15.5. Here is the output from the shell (Bash):

gcc -o build/user/gee/Mautocorr.o -c -O2 -x c -std=gnu11 -Wall -pedantic -fopenmp -Ibuild/include -I/usr/include/cblas build/user/gee/Mautocorr.c
gcc -o build/user/gee/autocorr.o -c -O2 -x c -std=gnu11 -Wall -pedantic -fopenmp -Ibuild/include -I/usr/include/cblas build/user/gee/autocorr.c
gcc -o build/user/gee/compress.o -c -O2 -x c -std=gnu11 -Wall -pedantic -fopenmp -Ibuild/include -I/usr/include/cblas build/user/gee/compress.c
gcc -o build/user/gee/sfautocorr -pthread -fopenmp build/user/gee/Mautocorr.o build/user/gee/autocorr.o build/user/gee/compress.o -Lbuild/lib -lrsf -lm -lblas -lcblas -llapack -lcblas -lgomp -lfftw3f -lfftw3 -lfftw3f_threads -lfftw3_threads
/usr/lib64/gcc/x86_64-suse-linux/7/../../../../x86_64-suse-linux/bin/ld: build/lib/librsf.a(file.o): in function `sf_complexwrite':
file.c:(.text+0x1a54): undefined reference to `xdr_float'
/usr/lib64/gcc/x86_64-suse-linux/7/../../../../x86_64-suse-linux/bin/ld: file.c:(.text+0x1a6b): undefined reference to `xdr_vector'
/usr/lib64/gcc/x86_64-suse-linux/7/../../../../x86_64-suse-linux/bin/ld: build/lib/librsf.a(file.o): in function `sf_complexread':
file.c:(.text+0x1bf2): undefined reference to `xdr_float'
/usr/lib64/gcc/x86_64-suse-linux/7/../../../../x86_64-suse-linux/bin/ld: file.c:(.text+0x1c09): undefined reference to `xdr_vector'
/usr/lib64/gcc/x86_64-suse-linux/7/../../../../x86_64-suse-linux/bin/ld: build/lib/librsf.a(file.o): in function `sf_charwrite':
file.c:(.text+0x1dc1): undefined reference to `xdr_opaque'
/usr/lib64/gcc/x86_64-suse-linux/7/../../../../x86_64-suse-linux/bin/ld: build/lib/librsf.a(file.o): in function `sf_ucharwrite':
file.c:(.text+0x1f71): undefined reference to `xdr_opaque'
/usr/lib64/gcc/x86_64-suse-linux/7/../../../../x86_64-suse-linux/bin/ld: build/lib/librsf.a(file.o): in function `sf_charread':
file.c:(.text+0x20ca): undefined reference to `xdr_opaque'
/usr/lib64/gcc/x86_64-suse-linux/7/../../../../x86_64-suse-linux/bin/ld: build/lib/librsf.a(file.o): in function `sf_ucharread':
file.c:(.text+0x22ca): undefined reference to `xdr_opaque'
/usr/lib64/gcc/x86_64-suse-linux/7/../../../../x86_64-suse-linux/bin/ld: build/lib/librsf.a(file.o): in function `sf_intwrite':
file.c:(.text+0x250c): undefined reference to `xdr_int'
/usr/lib64/gcc/x86_64-suse-linux/7/../../../../x86_64-suse-linux/bin/ld: file.c:(.text+0x2523): undefined reference to `xdr_vector'
/usr/lib64/gcc/x86_64-suse-linux/7/../../../../x86_64-suse-linux/bin/ld: build/lib/librsf.a(file.o): in function `sf_intread':
file.c:(.text+0x2684): undefined reference to `xdr_int'
/usr/lib64/gcc/x86_64-suse-linux/7/../../../../x86_64-suse-linux/bin/ld: file.c:(.text+0x269b): undefined reference to `xdr_vector'
/usr/lib64/gcc/x86_64-suse-linux/7/../../../../x86_64-suse-linux/bin/ld: build/lib/librsf.a(file.o): in function `sf_shortread':
file.c:(.text+0x2804): undefined reference to `xdr_int'
/usr/lib64/gcc/x86_64-suse-linux/7/../../../../x86_64-suse-linux/bin/ld: file.c:(.text+0x281a): undefined reference to `xdr_vector'
/usr/lib64/gcc/x86_64-suse-linux/7/../../../../x86_64-suse-linux/bin/ld: build/lib/librsf.a(file.o): in function `sf_longread':
file.c:(.text+0x2984): undefined reference to `xdr_int'
/usr/lib64/gcc/x86_64-suse-linux/7/../../../../x86_64-suse-linux/bin/ld: file.c:(.text+0x299b): undefined reference to `xdr_vector'
/usr/lib64/gcc/x86_64-suse-linux/7/../../../../x86_64-suse-linux/bin/ld: build/lib/librsf.a(file.o): in function `sf_shortwrite':
file.c:(.text+0x2bdc): undefined reference to `xdr_int'
/usr/lib64/gcc/x86_64-suse-linux/7/../../../../x86_64-suse-linux/bin/ld: file.c:(.text+0x2bf2): undefined reference to `xdr_vector'
/usr/lib64/gcc/x86_64-suse-linux/7/../../../../x86_64-suse-linux/bin/ld: build/lib/librsf.a(file.o): in function `sf_floatwrite':
file.c:(.text+0x2e3c): undefined reference to `xdr_float'
/usr/lib64/gcc/x86_64-suse-linux/7/../../../../x86_64-suse-linux/bin/ld: file.c:(.text+0x2e53): undefined reference to `xdr_vector'
/usr/lib64/gcc/x86_64-suse-linux/7/../../../../x86_64-suse-linux/bin/ld: build/lib/librsf.a(file.o): in function `sf_floatread':
file.c:(.text+0x2fb4): undefined reference to `xdr_float'
/usr/lib64/gcc/x86_64-suse-linux/7/../../../../x86_64-suse-linux/bin/ld: file.c:(.text+0x2fcb): undefined reference to `xdr_vector'
/usr/lib64/gcc/x86_64-suse-linux/7/../../../../x86_64-suse-linux/bin/ld: build/lib/librsf.a(file.o): in function `sf_setform':
file.c:(.text+0x81a): undefined reference to `xdrmem_create'
collect2: error: ld returned 1 exit status
scons: *** [build/user/gee/sfautocorr] Error 1
scons: building terminated because of errors.
make: *** [Makefile:7: install] Error 2

I am compiling Madagascar software from reproducibility.org. Done with configuration, installed dependencies, started compiling process. But there seems to be a problem with the configuration file in "build/user/gee". The configuration file is as below:

import os, sys, re, string
sys.path.append('../../framework')
import bldutil

progs = '''
autocorr burstnoise cconv conflict conv convf cpef1 cube deburst decon despike despike2 factorm factorn frame hconv heat3 helicon hole hpef idempatch imospray invbin invbin1 invrec1 kolmog levint light lopef losignoi lpef make maskinv misif miss miss1 msmiss mspef nhelicon npef parcel pefdeburst pfactor2 qdome randline sigmoid signoi splinebank splineplane streamissh synmarine syntop tentwt tspline ungrad velcon3 wavemovie wilson
'''

try:  # distributed version
    Import('env root pkgdir bindir libdir incdir')
    env = env.Clone()
except: # local version
    env = bldutil.Debug()
    root = None
    SConscript('../pwd/SConstruct')

src = Glob('[a-z]*.c')

dynpre = env.get('DYNLIB','') 

libs = [dynpre+'rsf']+env.get('LIBS',[])
dlibs = ['drsf']+env.get('LIBS',[])

env.Prepend(CPPPATH=['../../include'],
            LIBPATH=['../../lib'],
            LIBS=['libtirpc'])

dynlib = ('-static-intel' not in env.get('LINKFLAGS',''))

objects = []
dobjects = []
includes = []
for source in src:
    inc = env.RSF_Include(source,prefix='')
    obj = env.StaticObject(source)
    env.Ignore(inc,inc)
    env.Depends(obj,inc)

    objects.append(obj)
    includes.append(inc)

    if dynlib:
        obj = env.SharedObject(source)
        env.Depends(obj,inc)
        dobjects.append(obj)
        
lib = env.StaticLibrary('rsfgee',objects)
inc = env.Command('rsfgee.h',includes,Action(bldutil.__merge))

env.Install('../../lib',lib)
env.Install('../../include',inc)

if root:
    env.Install(libdir,lib)
    env.Install(incdir,inc)

if dynlib:
    dlib = env.SharedLibrary('rsfgee',dobjects,SHLIBPREFIX='libd',LIBS=dlibs)
    env.Install('../../lib',dlib)
    if root:
        install = env.Install(libdir,dlib)

        if dynpre and env['PLATFORM'] == 'darwin':
            env.AddPostAction(install,
            '%s -change build/api/c/libdrsf.dylib '
            '%s/libdrsf.dylib %s' % \
            (WhereIs('install_name_tool'),libdir,install[0]))


mains = Split(progs)
for prog in mains:
    sources = ['M' + prog]
    bldutil.depends(env,sources,'M'+prog)
    env.StaticObject('M'+prog+'.c')
    prog = env.Program(prog,[x + '.o' for x in sources],LIBS=libs)
    if root:
        env.Install(bindir,prog)

        if dynpre and env['PLATFORM'] == 'darwin':
            env.AddPostAction(install,
            '%s -change build/api/c/libdrsf.dylib '
            '%s/libdrsf.dylib %s' % \
            (WhereIs('install_name_tool'),libdir,install[0]))

######################################################################
# SELF-DOCUMENTATION
######################################################################
if root:
    user = os.path.basename(os.getcwd())
    main = 'sf%s.py' % user
    
    docs = [env.Doc(prog,'M' + prog) for prog in mains]
    env.Depends(docs,'#/framework/rsf/doc.py')  
    doc = env.RSF_Docmerge(main,docs)
    env.Install(pkgdir,doc)

The problem was present with other configuration files in other directories as well. By just adding 'libtirpc' to 'LIBS=[]' in 'env.Prepend' line, has solved the problem so far.

Please ask for any necessary info in a simple way!

Don't note my incompetence, I'm not a programmer! Thank You!

There are no Makefiles, only SCons and Python configuration files! Here is the general python configuration file:

ENV = {'PATH': '/usr/local/bin:/opt/bin:/bin:/usr/bin', 'LD_LIBRARY_PATH': ''}
RSFROOT = '/home/UserX/bin/Reproducibility'
AR = 'ar'
HAVE_RPC = True
JPEG = 'jpeg'
OPENGL = ['GL', 'GLU', 'glut']
OPENGLFLAGS = None
OPENGLPATH = None
MPICC = None
MPICXX = None
SPARSEPATH = ['/usr/include/suitesparse']
SPARSELIBS = ['umfpack', 'cholmod', 'amd', 'camd', 'colamd', 'ccolamd']
FFTW = 'fftw3f'
DFFTW = 'fftw3'
FFTWOMP = 'fftw3f_threads'
DFFTWOMP = 'fftw3_threads'
OMP = True
PTHREADS = True
BLAS = 'cblas'
LAPACK = ['lapack', 'cblas']
PPM = 'netpbm'
TIFF = 'tiff'
GD = 'gd'
GIFANIM = True
PLPLOT = 'plplot'
PLPLOTPATH = '/usr/include/plplot'
PLPLOTLIBPATH = None
FFMPEG = 'avcodec avutil'
FFMPEGPATH = ['/usr/include/ffmpeg', '/usr/include/ffmpeg/libavcodec']
CAIROPNG = 'cairo'
CAIROSVG = 'cairo'
CAIROPDF = 'cairo'
CAIROPATH = '/usr/include/cairo'
PPMPATH = '/usr/include/netpbm'
SFPEN = 'xtpen'
DYNLIB = ''
CC = 'gcc'
CFLAGS = '-O2 -x c -std=gnu11 -Wall -pedantic -fopenmp'
CPPPATH = ['/usr/include/cblas']
LIBPATH = []
LIBS = ['m', 'blas', 'cblas', 'lapack', 'cblas', 'gomp', 'fftw3f', 'fftw3', 'fftw3f_threads', 'fftw3_threads']
LINKFLAGS = ['-pthread', '-fopenmp']
XLIBPATH = ['/usr/lib/X11']
XLIBS = ['Xaw', 'Xt', 'X11']
XINC = ['/usr/include']
API = ['c++']
CXX = 'g++'
CXXFLAGS = '-O2 -std=gnu++17 -U__STRICT_ANSI__ -Wall -pedantic -fopenmp'
F77 = 'gfortran'
FORTRAN = 'gfortran'
F90 = 'gfortran'
F90FLAGS = '-O2 -fopenmp'
JAVAC = 'javac'
CUDA_TOOLKIT_PATH = None
NUMPY = True
SWIG = '/usr/bin/swig'

I don't want to modify this file, as it could add unnecessary linkage to programs that don't need it. (I think, maybe I am wrong!!).


Solution

  • Add tirpc library to the gcc command line in the Makefile:

       gcc -o build/..... -ltirpc
    

    You will have to find and change that file.