Linux 错误:未定义的引用
我正在使用LinuxMint11,并试图在我的机器上安装来自ProjectPurple的“sendip”工具 我不太了解makefile和linux内部构件 但是当尝试安装它时,会出现这些错误。请帮助我解决这个问题 这次对我来说最重要的是尽快把这个工具安装到我的机器上 它完美地安装在红帽机上,不会产生任何损坏 我在互联网上搜索,找到了很多解决方案,但没有一个解决方案,甚至有些看起来与我无关,但为了安全起见,我尝试了所有的解决方案Linux 错误:未定义的引用,linux,gcc,linker,makefile,installation,Linux,Gcc,Linker,Makefile,Installation,我正在使用LinuxMint11,并试图在我的机器上安装来自ProjectPurple的“sendip”工具 我不太了解makefile和linux内部构件 但是当尝试安装它时,会出现这些错误。请帮助我解决这个问题 这次对我来说最重要的是尽快把这个工具安装到我的机器上 它完美地安装在红帽机上,不会产生任何损坏 我在互联网上搜索,找到了很多解决方案,但没有一个解决方案,甚至有些看起来与我无关,但为了安全起见,我尝试了所有的解决方案 1. LDFLAGS='-ldl' make install 2.
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
生成文件内容:
#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
由于您使用的是Linux,因此似乎使用了LDFLAGS_Linux变量而不是LDFLAGS。尝试将
-ldl
添加到该行。由于您使用的是Linux,因此似乎使用了LDFLAGS\u Linux变量而不是LDFLAGS。尝试将-ldl
添加到该行。在Linux Mint 13和Ubuntu 12.04中遇到了相同的问题。以下是我为解决此问题所做的:
安装gcc-4.4
sudo apt get安装gcc-4.4
在Makefile中,将“cc”设置为指向gcc-4.4
CC=gcc-4.4
在Linux Mint 13和Ubuntu 12.04中遇到了相同的问题。以下是我为解决此问题所做的: 安装gcc-4.4 sudo apt get安装gcc-4.4 在Makefile中,将“cc”设置为指向gcc-4.4 CC=gcc-4.4
我更喜欢使用以下建议的解决方案: 及
我宁愿使用以下建议的解决方案: 及
如果在makefile中更改,会发生什么情况:
LDFLAGS=-g-rdynamic-lm-ldl
@Alessandro Pezzato没有更改,相同的错误如果在makefile中更改,会发生什么情况:LDFLAGS=-g-rdynamic-lm-ldl
@Alessandro Pezzato没有更改,同样的error@twalberg但它已经存在于Makefile中了。我也在上面添加了Makefile的内容,请看一看。oops。。。我的错。在其他行中,它位于-lm
之后,但在它出现在LDFLAGS\u LINUX之前,这一事实欺骗了我的眼睛…@twalberg,但它已经存在于Makefile中。我也在上面添加了Makefile的内容,请看一看。oops。。。我的错。事实上,它在其他行中出现在-lm
之后,但在它出现在LDFLAGS之前,LINUX欺骗了我的眼睛…谢谢这真的很有帮助,我希望它也能帮助像我这样的其他人…:-)我在Ubuntu 12.10上遇到了GCC4.7.2的同样问题。这是gcc的一个错误吗?谢谢你的帮助,我希望它也能帮助很多像我这样的人…:-)我在Ubuntu 12.10上遇到了GCC4.7.2的同样问题。那么这是gcc的错误吗?