1

我正在使用 linux-mint 11 并尝试在我的机器上从项目紫色安装“sendip”工具。

我对makefile和linux内部了解不多。

但是在尝试安装它时,出现这些错误。请帮我解决这个问题。

这次对我来说最重要的是尽快在我的机器上安装这个工具。

它完美地安装在红帽机器上,不会产生任何问题。

我在互联网上搜索并找到了许多解决方案,但它们都没有解决,即使有些看起来对我来说无关紧要,但为了安全起见,我都尝试了它们......

1. LDFLAGS='-ldl' make install
2. sudo apt-get install glibc*
3. make CFLAGS="${CFLAGS} -ldl"
4. sudo apt-get install libjpeg62-dev
5.  sudo apt-get install libdb-devel
6. sudo apt-get install libdbl

错误 :

  udit@udit-Notebook ~/Desktop/sendip-2.5-mec-0 $ make
   for subdir in mec ; do \
    cd $subdir ;\
    make  ;\
    cd ..  ;\
    done
make[1]: Entering directory `/home/udit/Desktop/sendip-2.5-mec-0/mec'
make[1]: Nothing to be done for `all'.
make[1]: Leaving directory `/home/udit/Desktop/sendip-2.5-mec-0/mec'
sh -c "if [ `uname` = Linux ] ; then \
gcc -o sendip -g  -rdynamic -ldl -lm -fPIC -fsigned-char -pipe -Wall -Wpointer-arith  
-Wwrite-strings -Wstrict-prototypes -Wnested-externs -Winline -Werror -g -Wcast-align  
-DSENDIP_LIBS=\"/usr/local/lib/sendip\" sendip.o gnugetopt.o gnugetopt1.o compact.o ; \
elif [ `uname` = SunOS ] ; then \
gcc -o sendip -g -lsocket -lnsl -lm -ldl -fPIC -fsigned-char -pipe -Wall  
-Wpointer-arith -Wwrite-strings -Wstrict-prototypes -Wnested-externs -Winline -Werror 
-g -Wcast-align -DSENDIP_LIBS=\"/usr/local/lib/sendip\" sendip.o gnugetopt.o  
gnugetopt1.o compact.o ;\
else \
gcc -o sendip -g -rdynamic -lm -fPIC -fsigned-char -pipe -Wall -Wpointer-arith -Wwrite- 
strings -Wstrict-prototypes -Wnested-externs -Winline -Werror -g -Wcast-align   
-DSENDIP_LIBS=\"/usr/local/lib/sendip\" sendip.o gnugetopt.o gnugetopt1.o compact.o ; \
fi"
sendip.o: In function `unload_modules':
/home/udit/Desktop/sendip-2.5-mec-0/sendip.c:211: undefined reference to `dlclose'
sendip.o: In function `load_module':
/home/udit/Desktop/sendip-2.5-mec-0/sendip.c:240: undefined reference to `dlopen'
/home/udit/Desktop/sendip-2.5-mec-0/sendip.c:241: undefined reference to `dlerror'
/home/udit/Desktop/sendip-2.5-mec-0/sendip.c:243: undefined reference to `dlopen'
/home/udit/Desktop/sendip-2.5-mec-0/sendip.c:244: undefined reference to `dlerror'
/home/udit/Desktop/sendip-2.5-mec-0/sendip.c:246: undefined reference to `dlopen'
/home/udit/Desktop/sendip-2.5-mec-0/sendip.c:247: undefined reference to `dlerror'
/home/udit/Desktop/sendip-2.5-mec-0/sendip.c:249: undefined reference to `dlopen'
/home/udit/Desktop/sendip-2.5-mec-0/sendip.c:250: undefined reference to `dlerror'
/home/udit/Desktop/sendip-2.5-mec-0/sendip.c:265: undefined reference to `dlsym'
/home/udit/Desktop/sendip-2.5-mec-0/sendip.c:266: undefined reference to `dlerror'
/home/udit/Desktop/sendip-2.5-mec-0/sendip.c:268: undefined reference to `dlclose'
/home/udit/Desktop/sendip-2.5-mec-0/sendip.c:272: undefined reference to `dlsym'
/home/udit/Desktop/sendip-2.5-mec-0/sendip.c:273: undefined reference to `dlerror'
/home/udit/Desktop/sendip-2.5-mec-0/sendip.c:275: undefined reference to `dlclose'
/home/udit/Desktop/sendip-2.5-mec-0/sendip.c:279: undefined reference to `dlsym'
/home/udit/Desktop/sendip-2.5-mec-0/sendip.c:280: undefined reference to `dlsym'
/home/udit/Desktop/sendip-2.5-mec-0/sendip.c:281: undefined reference to `dlerror'
/home/udit/Desktop/sendip-2.5-mec-0/sendip.c:282: undefined reference to `dlclose'
/home/udit/Desktop/sendip-2.5-mec-0/sendip.c:286: undefined reference to `dlsym'
/home/udit/Desktop/sendip-2.5-mec-0/sendip.c:287: undefined reference to `dlerror'
/home/udit/Desktop/sendip-2.5-mec-0/sendip.c:288: undefined reference to `dlclose'
/home/udit/Desktop/sendip-2.5-mec-0/sendip.c:292: undefined reference to `dlsym'
/home/udit/Desktop/sendip-2.5-mec-0/sendip.c:293: undefined reference to `dlerror'
/home/udit/Desktop/sendip-2.5-mec-0/sendip.c:294: undefined reference to `dlclose'
/home/udit/Desktop/sendip-2.5-mec-0/sendip.c:298: undefined reference to `dlsym'
/home/udit/Desktop/sendip-2.5-mec-0/sendip.c:299: undefined reference to `dlerror'
/home/udit/Desktop/sendip-2.5-mec-0/sendip.c:300: undefined reference to `dlclose'
collect2: ld returned 1 exit status
make: *** [sendip] Error 1

MakeFile 内容:

#configureable stuff
PREFIX ?= /usr/local
BINDIR ?= $(PREFIX)/bin
MANDIR ?= $(PREFIX)/share/man/man1
LIBDIR ?= $(PREFIX)/lib/sendip
#For most systems, this works
INSTALL ?= install
#For Solaris, you may need
#INSTALL=/usr/ucb/install

CFLAGS= -fPIC -fsigned-char -pipe -Wall -Wpointer-arith -Wwrite-strings \
        -Wstrict-prototypes -Wnested-externs -Winline -Werror -g   
-Wcast-align \
        -DSENDIP_LIBS=\"$(LIBDIR)\"
#-Wcast-align causes problems on solaris, but not serious ones
LDFLAGS=    -g -rdynamic -lm
#LDFLAGS_SOLARIS= -g -lsocket -lnsl -lm
LDFLAGS_SOLARIS= -g -lsocket -lnsl -lm -ldl
LDFLAGS_LINUX= -g  -rdynamic -ldl -lm
LIBCFLAGS= -shared
CC= gcc

PROGS= sendip
BASEPROTOS= ipv4.so ipv6.so
IPPROTOS= icmp.so tcp.so udp.so
UDPPROTOS= rip.so ripng.so ntp.so
TCPPROTOS= bgp.so
PROTOS= $(BASEPROTOS) $(IPPROTOS) $(UDPPROTOS) $(TCPPROTOS)
LIBS= libsendipaux.a
LIBOBJS= csum.o compact.o protoname.o headers.o parseargs.o
SUBDIRS= mec

all:    $(LIBS) subdirs sendip $(PROTOS) sendip.1 sendip.spec

#there has to be a nice way to do this
sendip: sendip.o    gnugetopt.o gnugetopt1.o compact.o
sh -c "if [ `uname` = Linux ] ; then \
$(CC) -o $@ $(LDFLAGS_LINUX) $(CFLAGS) $+ ; \
elif [ `uname` = SunOS ] ; then \
$(CC) -o $@ $(LDFLAGS_SOLARIS) $(CFLAGS) $+ ;\
else \
$(CC) -o $@ $(LDFLAGS) $(CFLAGS) $+ ; \
fi"

libsendipaux.a: $(LIBOBJS)
ar vr $@ $?

subdirs:
for subdir in $(SUBDIRS) ; do \
    cd $$subdir ;\
    make  ;\
    cd ..  ;\
    done

protoname.o:    mec/protoname.c
$(CC) -o $@ -c -I. $(CFLAGS) $+

headers.o:  mec/headers.c
$(CC) -o $@ -c -I. $(CFLAGS) $+

 parseargs.o:   mec/parseargs.c
$(CC) -o $@ -c -I. $(CFLAGS) $+

 sendip.1:  ./help2man $(PROGS) $(PROTOS) subdirs VERSION
        ./help2man -n "Send arbitrary IP packets" -N >sendip.1

 sendip.spec:   sendip.spec.in VERSION
        echo -n '%define ver ' >sendip.spec
        cat VERSION >>sendip.spec
        cat sendip.spec.in >>sendip.spec

 %.so: %.c $(LIBS)
        $(CC) -o $@ $(CFLAGS) $(LIBCFLAGS) $+ $(LIBS)

 .PHONY:    clean install

 clean:
        rm -f *.o *~ *.so $(PROTOS) $(PROGS) $(LIBS) core gmon.out
        for subdir in $(SUBDIRS) ; do \
            cd $$subdir ;\
            make clean ;\
            cd ..  ;\
            done

  veryclean:
        make clean
        rm -f sendip.spec sendip.1

  install:      all
        [ -d $(LIBDIR) ] || mkdir -p $(LIBDIR)
        [ -d $(BINDIR) ] || mkdir -p $(BINDIR)
        [ -d $(MANDIR) ] || mkdir -p $(MANDIR)
        $(INSTALL) -m 755 $(PROGS) $(BINDIR)
        $(INSTALL) -m 644 sendip.1 $(MANDIR)
        $(INSTALL) -m 755 $(PROTOS) $(LIBDIR)
        for subdir in $(SUBDIRS) ; do \
            cd $$subdir ;\
            make install ;\
            cd ..  ;\
            done
4

3 回答 3

4

在 Linux Mint 13 和 Ubuntu 12.04 中遇到了同样的问题。这是我为解决此问题所做的工作:

安装 gcc-4.4

sudo apt-get 安装 gcc-4.4

在 Makefile 中,将“cc”设置为指向 gcc-4.4。

抄送= gcc-4.4

于 2012-10-25T02:28:44.343 回答
0

由于您使用的是 Linux,因此似乎使用的是 LDFLAGS_LINUX 变量而不是 LDFLAGS。尝试添加-ldl到该行。

于 2012-06-13T15:24:14.433 回答
0

我宁愿使用以下建议的解决方案:

为什么我在尝试创建共享对象时收到 gcc“未定义引用”错误?

回答:即使 -lm 是编译标志,对“pow”的未定义引用也是如此。[C]

于 2016-03-08T16:03:20.540 回答