Undefined reference to...

This is a discussion on Undefined reference to... within the C Programming forums, part of the General Programming Boards category; In the intall notes it says: Code: ./configure make make test (optional) make install (as root) ------------------------------------------------------------------------ In the install-sh ...

  1. #16
    Registered User
    Join Date
    Oct 2009
    Posts
    10
    In the intall notes it says:

    Code:
    ./configure
    make
    make test (optional)
    make install (as root)
    ------------------------------------------------------------------------
    In the install-sh

    Code:
    #!/bin/sh
    #
    # install - install a program, script, or datafile
    # This comes from X11R5 (mit/util/scripts/install.sh).
    #
    # Copyright 1991 by the Massachusetts Institute of Technology
    #
    # Permission to use, copy, modify, distribute, and sell this software and its
    # documentation for any purpose is hereby granted without fee, provided that
    # the above copyright notice appear in all copies and that both that
    # copyright notice and this permission notice appear in supporting
    # documentation, and that the name of M.I.T. not be used in advertising or
    # publicity pertaining to distribution of the software without specific,
    # written prior permission.  M.I.T. makes no representations about the
    # suitability of this software for any purpose.  It is provided "as is"
    # without express or implied warranty.
    #
    # Calling this script install-sh is preferred over install.sh, to prevent
    # `make' implicit rules from creating a file called install from it
    # when there is no Makefile.
    #
    # This script is compatible with the BSD install script, but was written
    # from scratch.  It can only install one file at a time, a restriction
    # shared with many OS's install programs.
    
    
    # set DOITPROG to echo to test this script
    
    # Don't use :- since 4.3BSD and earlier shells don't like it.
    doit="${DOITPROG-}"
    
    
    # put in absolute paths if you don't have them in your path; or use env. vars.
    
    mvprog="${MVPROG-mv}"
    cpprog="${CPPROG-cp}"
    chmodprog="${CHMODPROG-chmod}"
    chownprog="${CHOWNPROG-chown}"
    chgrpprog="${CHGRPPROG-chgrp}"
    stripprog="${STRIPPROG-strip}"
    rmprog="${RMPROG-rm}"
    mkdirprog="${MKDIRPROG-mkdir}"
    
    transformbasename=""
    transform_arg=""
    instcmd="$mvprog"
    chmodcmd="$chmodprog 0755"
    chowncmd=""
    chgrpcmd=""
    stripcmd=""
    rmcmd="$rmprog -f"
    mvcmd="$mvprog"
    src=""
    dst=""
    dir_arg=""
    
    while [ x"$1" != x ]; do
        case $1 in
    	-c) instcmd="$cpprog"
    	    shift
    	    continue;;
    
    	-d) dir_arg=true
    	    shift
    	    continue;;
    
    	-m) chmodcmd="$chmodprog $2"
    	    shift
    	    shift
    	    continue;;
    
    	-o) chowncmd="$chownprog $2"
    	    shift
    	    shift
    	    continue;;
    
    	-g) chgrpcmd="$chgrpprog $2"
    	    shift
    	    shift
    	    continue;;
    
    	-s) stripcmd="$stripprog"
    	    shift
    	    continue;;
    
    	-t=*) transformarg=`echo $1 | sed 's/-t=//'`
    	    shift
    	    continue;;
    
    	-b=*) transformbasename=`echo $1 | sed 's/-b=//'`
    	    shift
    	    continue;;
    
    	*)  if [ x"$src" = x ]
    	    then
    		src=$1
    	    else
    		# this colon is to work around a 386BSD /bin/sh bug
    		:
    		dst=$1
    	    fi
    	    shift
    	    continue;;
        esac
    done
    
    if [ x"$src" = x ]
    then
    	echo "install:	no input file specified"
    	exit 1
    else
    	true
    fi
    
    if [ x"$dir_arg" != x ]; then
    	dst=$src
    	src=""
    	
    	if [ -d $dst ]; then
    		instcmd=:
    		chmodcmd=""
    	else
    		instcmd=mkdir
    	fi
    else
    
    # Waiting for this to be detected by the "$instcmd $src $dsttmp" command
    # might cause directories to be created, which would be especially bad 
    # if $src (and thus $dsttmp) contains '*'.
    
    	if [ -f $src -o -d $src ]
    	then
    		true
    	else
    		echo "install:  $src does not exist"
    		exit 1
    	fi
    	
    	if [ x"$dst" = x ]
    	then
    		echo "install:	no destination specified"
    		exit 1
    	else
    		true
    	fi
    
    # If destination is a directory, append the input filename; if your system
    # does not like double slashes in filenames, you may need to add some logic
    
    	if [ -d $dst ]
    	then
    		dst="$dst"/`basename $src`
    	else
    		true
    	fi
    fi
    
    ## this sed command emulates the dirname command
    dstdir=`echo $dst | sed -e 's,[^/]*$,,;s,/$,,;s,^$,.,'`
    
    # Make sure that the destination directory exists.
    #  this part is taken from Noah Friedman's mkinstalldirs script
    
    # Skip lots of stat calls in the usual case.
    if [ ! -d "$dstdir" ]; then
    defaultIFS='	
    '
    IFS="${IFS-${defaultIFS}}"
    
    oIFS="${IFS}"
    # Some sh's can't handle IFS=/ for some reason.
    IFS='%'
    set - `echo ${dstdir} | sed -e 's@/@%@g' -e 's@^%@/@'`
    IFS="${oIFS}"
    
    pathcomp=''
    
    while [ $# -ne 0 ] ; do
    	pathcomp="${pathcomp}${1}"
    	shift
    
    	if [ ! -d "${pathcomp}" ] ;
            then
    		$mkdirprog "${pathcomp}"
    	else
    		true
    	fi
    
    	pathcomp="${pathcomp}/"
    done
    fi
    
    if [ x"$dir_arg" != x ]
    then
    	$doit $instcmd $dst &&
    
    	if [ x"$chowncmd" != x ]; then $doit $chowncmd $dst; else true ; fi &&
    	if [ x"$chgrpcmd" != x ]; then $doit $chgrpcmd $dst; else true ; fi &&
    	if [ x"$stripcmd" != x ]; then $doit $stripcmd $dst; else true ; fi &&
    	if [ x"$chmodcmd" != x ]; then $doit $chmodcmd $dst; else true ; fi
    else
    
    # If we're going to rename the final executable, determine the name now.
    
    	if [ x"$transformarg" = x ] 
    	then
    		dstfile=`basename $dst`
    	else
    		dstfile=`basename $dst $transformbasename | 
    			sed $transformarg`$transformbasename
    	fi
    
    # don't allow the sed command to completely eliminate the filename
    
    	if [ x"$dstfile" = x ] 
    	then
    		dstfile=`basename $dst`
    	else
    		true
    	fi
    
    # Make a temp file name in the proper directory.
    
    	dsttmp=$dstdir/#inst.$$#
    
    # Move or copy the file name to the temp name
    
    	$doit $instcmd $src $dsttmp &&
    
    	trap "rm -f ${dsttmp}" 0 &&
    
    # and set any options; do chmod last to preserve setuid bits
    
    # If any of these fail, we abort the whole thing.  If we want to
    # ignore errors from any of these, just make sure not to ignore
    # errors from the above "$doit $instcmd $src $dsttmp" command.
    
    	if [ x"$chowncmd" != x ]; then $doit $chowncmd $dsttmp; else true;fi &&
    	if [ x"$chgrpcmd" != x ]; then $doit $chgrpcmd $dsttmp; else true;fi &&
    	if [ x"$stripcmd" != x ]; then $doit $stripcmd $dsttmp; else true;fi &&
    	if [ x"$chmodcmd" != x ]; then $doit $chmodcmd $dsttmp; else true;fi &&
    
    # Now rename the file to the real destination.
    
    	$doit $rmcmd -f $dstdir/$dstfile &&
    	$doit $mvcmd $dsttmp $dstdir/$dstfile 
    
    fi &&
    
    
    exit 0
    ---------------------------------------------------------------------------------------------

    Makefile.in

    Code:
    # Makefile prototype for configure
    # Copyright 2004 Phil Karn, KA9Q
    # May be used under the terms of the GNU Lesser General Public License (LGPL)
    
    # @configure_input@
    srcdir = @srcdir@
    prefix = @prefix@
    exec_prefix=@exec_prefix@
    VPATH = @srcdir@
    CC=@CC@
    LIBS=@MLIBS@ fec.o sim.o viterbi27.o viterbi27_port.o viterbi29.o viterbi29_port.o \
    	viterbi39.o viterbi39_port.o \
    	viterbi615.o viterbi615_port.o encode_rs_char.o encode_rs_int.o encode_rs_8.o \
    	decode_rs_char.o decode_rs_int.o decode_rs_8.o \
    	init_rs_char.o init_rs_int.o ccsds_tab.o \
    	encode_rs_ccsds.o decode_rs_ccsds.o ccsds_tal.o \
    	dotprod.o dotprod_port.o \
    	peakval.o peakval_port.o \
    	sumsq.o sumsq_port.o
    
    CFLAGS=@CFLAGS@ -I. -Wall @ARCH_OPTION@
    
    SHARED_LIB=@SH_LIB@
    
    all: libfec.a $(SHARED_LIB)
    
    test: vtest27 vtest29 vtest39 vtest615 rstest dtest sumsq_test peaktest
    	@echo "Correctness tests:"
    	./vtest27 -e 3.0 -n 1000 -v
    	./vtest29 -e 2.5 -n 1000 -v
    	./vtest39 -e 2.5 -n 1000 -v
    	./vtest615 -e 1.0 -n 100 -v
    	./rstest
    	./dtest
    	./sumsq_test
    	./peaktest
    	@echo "Speed tests:"
    	./vtest27
    	./vtest29
    	./vtest39
    	./vtest615
    
    install: all
    	mkdir -p @libdir@ 
    	install -m 644 -p $(SHARED_LIB) libfec.a @libdir@
    #	(cd @libdir@;ln -f -s $(SHARED_LIB) libfec.so)
    	@REBIND@
    	mkdir -p @includedir@
    	install -m 644 -p fec.h @includedir@
    	mkdir -m 0755 -p @mandir@/man3
    	install -m 644 -p simd-viterbi.3 rs.3 dsp.3 @mandir@/man3
    
    peaktest: peaktest.o libfec.a
    	gcc -g -o $@ $^
    
    sumsq_test: sumsq_test.o libfec.a
    	gcc -g -o $@ $^
    
    dtest: dtest.o libfec.a
    	gcc -g -o $@ $^ -lm
    
    vtest27: vtest27.o libfec.a
    	gcc -g -o $@ $^ -lm
    
    vtest29: vtest29.o libfec.a
    	gcc -g -o $@ $^ -lm
    
    vtest39: vtest39.o libfec.a
    	gcc -g -o $@ $^ -lm
    
    vtest615: vtest615.o libfec.a
    	gcc -g -o $@ $^ -lm
    
    rstest: rstest.o libfec.a
    	gcc -g -o $@ $^
    
    rs_speedtest: rs_speedtest.o libfec.a
    	gcc -g -o $@ $^	
    
    # for some reason, the test programs without args segfault on the PPC with -O2 optimization. Dunno why - compiler bug?
    vtest27.o: vtest27.c fec.h
    	gcc -g -c $<
    
    vtest29.o: vtest29.c fec.h
    	gcc -g -c $<
    
    vtest39.o: vtest39.c fec.h
    	gcc -g -c $<
    
    vtest615.o: vtest615.c fec.h
    	gcc -g -c $<
    
    libfec.a: $(LIBS)
    	ar rv $@ $^
    	ranlib libfec.a
    
    # for Darwin
    libfec.dylib: $(LIBS)
    	$(CC) -dynamiclib -install_name $@ -o $@ $^
    
    # for Linux et al
    libfec.so: $(LIBS)
    	gcc -shared -Xlinker -soname=$@ -o $@ -Wl,-whole-archive $^ -Wl,-no-whole-archive -lc
    
    dotprod.o: dotprod.c fec.h
    
    dotprod_port.o: dotprod_port.c fec.h
    
    viterbi27.o: viterbi27.c fec.h
    
    viterbi27_port.o: viterbi27_port.c fec.h
    
    viterbi29.o: viterbi29.c fec.h
    
    viterbi39.o: viterbi39.c fec.h
    
    viterbi39_port.o: viterbi39_port.c fec.h
    
    viterbi39_sse2.o: viterbi39_sse2.c fec.h
    
    viterbi39_sse.o: viterbi39_sse.c fec.h
    
    viterbi39_mmx.o: viterbi39_mmx.c fec.h
    
    encode_rs_char.o: encode_rs_char.c char.h rs-common.h
    
    encode_rs_int.o: encode_rs_int.c int.h rs-common.h
    
    encode_rs_8.o: encode_rs_8.c fixed.h
    
    encode_rs_av.o: encode_rs_av.c fixed.h
    
    decode_rs_char.o: decode_rs_char.c char.h rs-common.h
    
    decode_rs_int.o: decode_rs_int.c int.h rs-common.h
    
    decode_rs_8.o: decode_rs_8.c fixed.h
    
    init_rs_char.o: init_rs_char.c char.h rs-common.h
    
    init_rs_int.o: init_rs_int.c int.h rs-common.h
    
    ccsds_tab.o: ccsds_tab.c
    
    ccsds_tab.c: gen_ccsds
    	./gen_ccsds > ccsds_tab.c
    
    gen_ccsds: gen_ccsds.o init_rs_char.o
    	gcc -o $@ $^
    
    gen_ccsds.o: gen_ccsds.c
    	gcc  $(CFLAGS) -c -o $@ $<
    
    ccsds_tal.o: ccsds_tal.c
    
    ccsds_tal.c: gen_ccsds_tal
    	./gen_ccsds_tal > ccsds_tal.c
    
    exercise_char.o: exercise.c
    	gcc $(CFLAGS) -c -o $@ $<
    
    exercise_int.o: exercise.c
    	gcc -DBIGSYM=1 $(CFLAGS) -c -o $@ $<
    
    exercise_8.o: exercise.c
    	gcc -DFIXED=1 $(CFLAGS) -c -o $@ $<
    
    exercise_ccsds.o: exercise.c
    	gcc -DCCSDS=1 $(CFLAGS) -c -o $@ $<
    
    viterbi27.o: viterbi27.c fec.h
    
    viterbi27_port.o: viterbi27_port.c fec.h
    
    viterbi27_av.o: viterbi27_av.c fec.h
    
    viterbi27_mmx.o: viterbi27_mmx.c fec.h
    	gcc $(CFLAGS) -mmmx -c -o $@ $<
    
    viterbi27_sse.o: viterbi27_sse.c fec.h
    	gcc $(CFLAGS) -msse -c -o $@ $<
    
    viterbi27_sse2.o: viterbi27_sse2.c fec.h
    	gcc $(CFLAGS) -msse2 -c -o $@ $<
    
    viterbi29.o: viterbi29.c fec.h
    
    viterbi29_port.o: viterbi29_port.c fec.h
    
    viterbi29_av.o: viterbi29_av.c fec.h
    
    viterbi29_mmx.o: viterbi29_mmx.c fec.h
    	gcc $(CFLAGS) -mmmx -c -o $@ $<
    
    viterbi29_sse.o: viterbi29_sse.c fec.h
    	gcc $(CFLAGS) -msse -c -o $@ $<
    
    viterbi29_sse2.o: viterbi29_sse2.c fec.h
    	gcc $(CFLAGS) -msse2 -c -o $@ $<
    
    viterbi39.o: viterbi39.c fec.h
    
    viterbi39_port.o: viterbi39_port.c fec.h
    
    viterbi39_av.o: viterbi39_av.c fec.h
    
    viterbi39_mmx.o: viterbi39_mmx.c fec.h
    	gcc $(CFLAGS) -mmmx -c -o $@ $<
    
    viterbi39_sse.o: viterbi39_sse.c fec.h
    	gcc $(CFLAGS) -msse -c -o $@ $<
    
    viterbi39_sse2.o: viterbi39_sse2.c fec.h
    	gcc $(CFLAGS) -msse2 -c -o $@ $<
    
    viterbi615.o: viterbi615.c fec.h
    
    viterbi615_port.o: viterbi615_port.c fec.h
    
    viterbi615_av.o: viterbi615_av.c fec.h
    
    viterbi615_mmx.o: viterbi615_mmx.c fec.h
    	gcc $(CFLAGS) -mmmx -c -o $@ $<
    
    viterbi615_sse.o: viterbi615_sse.c fec.h
    	gcc $(CFLAGS) -msse -c -o $@ $<
    
    viterbi615_sse2.o: viterbi615_sse2.c fec.h
    	gcc $(CFLAGS) -msse2 -c -o $@ $<
    
    cpu_mode_x86.o: cpu_mode_x86.c fec.h
    
    cpu_mode_ppc.o: cpu_mode_ppc.c fec.h
    
    
    clean:
    	rm -f *.o $(SHARED_LIB) *.a rs_speedtest peaktest sumsq_test dtest vtest27 vtest29 vtest39 vtest615 rstest ccsds_tab.c ccsds_tal.c gen_ccsds gen_ccsds_tal core
    	rm -rf autom4te.cache
    
    distclean: clean
    	rm -f config.log config.cache config.status config.h makefile
    --------------------------------------------------------------------------
    I don't extract of them what I must do... :S

  2. #17
    Captain Crash brewbuck's Avatar
    Join Date
    Mar 2007
    Location
    Portland, OR
    Posts
    7,230
    Quote Originally Posted by legendus View Post
    Should I use anothe programming enviroment?.
    Yes, I recommend this strategy going forward. Whenever anything doesn't work, replace every component of the system except the one YOU wrote. The problem has to be somewhere else. For good measure, throw the entire computer out the window and get a new one. With Windows 7 on it. Yeah, that's the ticket, Windows 7.
    Code:
    //try
    //{
    	if (a) do { f( b); } while(1);
    	else   do { f(!b); } while(1);
    //}

  3. #18
    Registered User
    Join Date
    Oct 2009
    Posts
    10
    mmmm...ok...when we are going to do a humor festival we are going to call you
    Last edited by legendus; 10-24-2009 at 11:24 AM.

  4. #19
    and the Hat of Guessing tabstop's Avatar
    Join Date
    Nov 2007
    Posts
    14,185
    Okay, so libfec.a is your library, and it requires you to have all of these:
    Code:
    LIBS=@MLIBS@ fec.o sim.o viterbi27.o viterbi27_port.o viterbi29.o viterbi29_port.o \
    	viterbi39.o viterbi39_port.o \
    	viterbi615.o viterbi615_port.o encode_rs_char.o encode_rs_int.o encode_rs_8.o \
    	decode_rs_char.o decode_rs_int.o decode_rs_8.o \
    	init_rs_char.o init_rs_int.o ccsds_tab.o \
    	encode_rs_ccsds.o decode_rs_ccsds.o ccsds_tal.o \
    	dotprod.o dotprod_port.o \
    	peakval.o peakval_port.o \
    	sumsq.o sumsq_port.o
    So each of the corresponding .c files need to be in your library project.

  5. #20
    Registered User
    Join Date
    Oct 2009
    Posts
    10
    Hello

    I have done it like you said, but I didn't see to files that it said that I must include:

    ccsds_tab and ccsdstal

    Even so, I can compile it without problem and add to the project. And well, it's not perfect, but I pass from 9 errors to 6.

    And well...I remember you that I'm doing all of this to open image and decoding them... and I have done it by other way, programming the open of a picture with the format that it pretends to receive.

    Even so, I would like to learn how to do this (put a library), but I understand that it can be tiring by your side. So, if you want we can go on or let it.

    Anyway...thank you so much, you have been very patient with me .
    Last edited by legendus; 10-25-2009 at 07:00 AM.

Page 2 of 2 FirstFirst 12
Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Getting an error with OpenGL: collect2: ld returned 1 exit status
    By Lorgon Jortle in forum C++ Programming
    Replies: 6
    Last Post: 05-08-2009, 08:18 PM
  2. Undefined Reference Compiling Error
    By AlakaAlaki in forum C++ Programming
    Replies: 1
    Last Post: 06-27-2008, 11:45 AM
  3. Screwy Linker Error - VC2005
    By Tonto in forum C++ Programming
    Replies: 5
    Last Post: 06-19-2007, 02:39 PM
  4. C OpenGL Compiler Error?
    By Matt3000 in forum C Programming
    Replies: 12
    Last Post: 07-07-2006, 04:42 PM
  5. c++ linking problem for x11
    By kron in forum Linux Programming
    Replies: 1
    Last Post: 11-19-2004, 09:18 AM

Tags for this Thread


1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21