kompilieren in cplot mit nrutil.h führt zu undefined reference



  • Hallo,

    ich bin leider sehr programmier-unerfahren, aber suche nun schon nach ein paar Stunden nach Lösungen zu meinem Problem und werde nicht fündig, deswegen hoffe ich, dass ich hier vielleicht eine Antwort bekomme.
    Verzeiht evtl falsche oder unpräzise Beschreibungen/Bezeichnung, sie sind meiner Unerfahrenheit geschuldet.

    Ich versuche C++ Code zu kompilieren innerhalb eines Programms Namens C-Plot. Dabei wir ein Makefile aufgerufen, der folgendermaßen aussieht:

    #!/bin/sh
    #
    #   "@(#)makefunc.sh	4.6  02/21/03 CSS"
    #   "C-PLOT Release 4"
    #
    #   "Copyright (c) 1985-1991,1992,2000,2003"
    #   "by Certified Scientific Software"
    #   "All rights reserved."
    #   "Copyrighted as an unpublished work."
    #
    
    CFLAGS=${CFLAGS-"-O"}
    CLIBS=${CLIBS-"-ltermlib -lm"}
    CC=${CC-"cc"}
    
    PATH=/bin:$PATH
    TEST=test
    GFLAG=
    
    if $TEST "$CPLOTHOME" = ""
    then
        if $TEST -d "/usr/local/cplot"
        then
    	CPLOTHOME=/usr/local/cplot
        else
    	CPLOTHOME=/usr/cplot
        fi
    fi
    
    # Get CFLAGS and CLIBS from system config file
    if $TEST -f $CPLOTHOME/cplot_config
    then
    	. $CPLOTHOME/cplot_config
    elif $TEST -f $CPLOTHOME/cplot_config_
    then
    	. $CPLOTHOME/cplot_config_
    fi
    # Check user's local definitions:
    if $TEST -f $HOME/.cplot_init
    then
    	. $HOME/.cplot_init
    fi
    
    case $# in
     1) ;;
     *) echo "Usage:  makefunc function" ; exit 1 ;;
    esac
    
    ARG=$1
    
    FNAM=`echo $ARG | sed 's;.*/;;'`
    case _$ARG in
      _)      echo "Usage:  makefunc function" ; exit 1 ;;
      _$FNAM) DIREC=. ;;
      *)      DIREC=`echo $ARG | sed 's;^\(.*\)/'$FNAM'$;\1;'`
    esac
    
    case $FNAM in
      *.c) FNAM=`echo $FNAM | sed 's/.c$//'` ;;
    esac
    
    case $FNAM in
      *.[1234]) OVERHEAD=$CPLOTHOME/overhead/p_overhead.o ;;
      *.5)      OVERHEAD=$CPLOTHOME/overhead/p_libfit.a ;;
      *)        echo "Require type 1-5 function name" ; exit 1 ;;
    esac
    
    USR_CMD=`grep cplot_compile: $DIREC/$FNAM.c`
    
    case _"$USR_CMD" in
      _)
    	$TEST -r $DIREC/Makefile \
    		&& grep -s " *$FNAM *:" $DIREC/Makefile 2>/dev/null \
    		&& USR_CMD=MaKe
    	$TEST -r $DIREC/makefile \
    		&& grep -s " *$FNAM *:" $DIREC/makefile 2>/dev/null \
    		&& USR_CMD=MaKe
    	;;
    esac
    
    case _"$USR_CMD" in
      _) ;;
      *) USR_CMD=`echo "$USR_CMD" | sed -e 's@^.*cplot_compile:@@g'` ;;
    esac
    
    case _"$USR_CMD" in
      _) cd $DIREC ; \
    	$CC $GFLAG $CFLAGS -I$CPLOTHOME/include $FNAM.c $OVERHEAD $CLIBS
         case $? in
    	0) { $TEST -f a.out && mv a.out $FNAM; } \
    		|| { $TEST -f a.exe && mv a.exe $FNAM; } ; exit 0 ;;
    	*) exit $? ;;
         esac
         ;;
      _MaKe)
         cd $DIREC ; make $FNAM
         exit $?
         ;;
      *) cd $DIREC ; $USR_CMD
         exit $?
         ;;
    esac
    

    Offensichtlich liest er die Datei cplot_config aus, die wie folg ausschaut:

    CFLAGS="-O  "
    CLIBS="-Wl,-Bstatic -L/usr/lib -lncurses -Wl,-Bdynamic -L/home/user/cplot/functions -lm"
    DEVICE=/dev/usblp0
    BAUD=9600
    GPIB=0
    NPTS=8192
    FILTER=x11
    

    Das Verzeichnis ~/cplot/functions hab ich dabei selbst hinzugefügt, da dort die Datei
    nrutil.h liegt. In dieser ist auch die arrays(?) vecot, free_vector u.a. definiert.

    Sie sieht so aus:

    #ifndef _NR_UTILS_H_
    #define _NR_UTILS_H_
    
    static float sqrarg;
    #define SQR(a) ((sqrarg=(a)) == 0.0 ? 0.0 : sqrarg*sqrarg)
    
    static double dsqrarg;
    #define DSQR(a) ((dsqrarg=(a)) == 0.0 ? 0.0 : dsqrarg*dsqrarg)
    
    static double dmaxarg1,dmaxarg2;
    #define DMAX(a,b) (dmaxarg1=(a),dmaxarg2=(b),(dmaxarg1) > (dmaxarg2) ?\
            (dmaxarg1) : (dmaxarg2))
    
    static double dminarg1,dminarg2;
    #define DMIN(a,b) (dminarg1=(a),dminarg2=(b),(dminarg1) < (dminarg2) ?\
            (dminarg1) : (dminarg2))
    
    static float maxarg1,maxarg2;
    #define FMAX(a,b) (maxarg1=(a),maxarg2=(b),(maxarg1) > (maxarg2) ?\
            (maxarg1) : (maxarg2))
    
    static float minarg1,minarg2;
    #define FMIN(a,b) (minarg1=(a),minarg2=(b),(minarg1) < (minarg2) ?\
            (minarg1) : (minarg2))
    
    static long lmaxarg1,lmaxarg2;
    #define LMAX(a,b) (lmaxarg1=(a),lmaxarg2=(b),(lmaxarg1) > (lmaxarg2) ?\
            (lmaxarg1) : (lmaxarg2))
    
    static long lminarg1,lminarg2;
    #define LMIN(a,b) (lminarg1=(a),lminarg2=(b),(lminarg1) < (lminarg2) ?\
            (lminarg1) : (lminarg2))
    
    static int imaxarg1,imaxarg2;
    #define IMAX(a,b) (imaxarg1=(a),imaxarg2=(b),(imaxarg1) > (imaxarg2) ?\
            (imaxarg1) : (imaxarg2))
    
    static int iminarg1,iminarg2;
    #define IMIN(a,b) (iminarg1=(a),iminarg2=(b),(iminarg1) < (iminarg2) ?\
            (iminarg1) : (iminarg2))
    
    #define SIGN(a,b) ((b) >= 0.0 ? fabs(a) : -fabs(a))
    
    #if defined(__STDC__) || defined(ANSI) || defined(NRANSI) /* ANSI */
    
    void nrerror(char error_text[]);
    float *vector(long nl, long nh);
    int *ivector(long nl, long nh);
    unsigned char *cvector(long nl, long nh);
    unsigned long *lvector(long nl, long nh);
    double *dvector(long nl, long nh);
    float **matrix(long nrl, long nrh, long ncl, long nch);
    double **dmatrix(long nrl, long nrh, long ncl, long nch);
    int **imatrix(long nrl, long nrh, long ncl, long nch);
    short int **simatrix(long nrl, long nrh, long ncl, long nch);
    float **submatrix(float **a, long oldrl, long oldrh, long oldcl, long oldch,
    	long newrl, long newcl);
    float **convert_matrix(float *a, long nrl, long nrh, long ncl, long nch);
    float ***f3tensor(long nrl, long nrh, long ncl, long nch, long ndl, long ndh);
    double ***d3tensor(long nrl, long nrh, long ncl, long nch, long ndl, long ndh);
    int ***i3tensor(long nrl, long nrh, long ncl, long nch, long ndl, long ndh);
    short int ***si3tensor(long nrl, long nrh, long ncl, long nch, long ndl, long ndh);
    void free_vector(float *v, long nl, long nh);
    void free_ivector(int *v, long nl, long nh);
    void free_cvector(unsigned char *v, long nl, long nh);
    void free_lvector(unsigned long *v, long nl, long nh);
    void free_dvector(double *v, long nl, long nh);
    void free_matrix(float **m, long nrl, long nrh, long ncl, long nch);
    void free_dmatrix(double **m, long nrl, long nrh, long ncl, long nch);
    void free_imatrix(int **m, long nrl, long nrh, long ncl, long nch);
    void free_simatrix(short int **m, long nrl, long nrh, long ncl, long nch);
    void free_submatrix(float **b, long nrl, long nrh, long ncl, long nch);
    void free_convert_matrix(float **b, long nrl, long nrh, long ncl, long nch);
    void free_f3tensor(float ***t, long nrl, long nrh, long ncl, long nch,
    	long ndl, long ndh);
    void free_d3tensor(double ***t, long nrl, long nrh, long ncl, long nch,
    	long ndl, long ndh);
    void free_i3tensor(int ***t, long nrl, long nrh, long ncl, long nch,
    	long ndl, long ndh);
    void free_si3tensor(short int ***t, long nrl, long nrh, long ncl, long nch,
    	long ndl, long ndh);
    
    #endif /* ANSI */
    
    #endif /* _NR_UTILS_H_ */
    

    Wenn ich das ganze nun zu kompilieren Versuche bekomme ich die Meldung

    Compiling...
    /tmp/ccix5F7n.o: In function `odeint':
    modell.5.c:(.text+0x8d7): undefined reference to `vector'
    .
    .
    .
    /tmp/ccix5F7n.o:modell.5.c:(.text+0xd17): more undefined references to `vector' follow
    modell.5.c:(.text+0x1016): undefined reference to `rkqs'
    collect2: ld returned 1 exit status
    There's a question as to the existence of "/home/user/cplot/functions/modell.5"
    

    Offenbar funktionieren irgendwie die Bibliotheken nicht richtig in denen vector etc definiert sind.
    Die nrutil.h müsste aber gefunden werden, habe das Verzeichnis ja explizit mit angegeben.

    Woran kann das liegen? Fehlt die Bibliothek doch irgendwie? Der Code selbst dürfte keine Fehler enthalten, denn er wurde in der Form auch schon zum laufen bekommen (leider nicht von mir).

    Hoffe ihr könnt mit der Problembeschreibung etwas anfangen, sonst bitte rückfragen.
    Vielen Dank!


Anmelden zum Antworten