当我尝试使用以下命令在linux机器上获取我的一个库时:
go get -t github.com/bakape/thumbnailer
然后我收到此错误消息:
-#github.com/bakape/thumbnailer / usr / bin / ld:/ usr / bin / ld:/usr/local/lib/libGraphicsMagick.a(magick_libGraphicsMagick_la-blob.o):对符号'gzclose的未定义引用' //lib/x86_64-linux-gnu/libz.so.1:添加符号时出错:命令行缺少DSO collect2:错误:ld返回1退出状态
遇到此错误的人说这是链接错误,他们通过在Makefile中添加一些其他标签来解决此问题。我也这样做了,但这对我没有用。我尝试了很多解决方案,但似乎没有任何效果。
我正在使用以下库: https://github.com/bakape/thumbnailer
这是Makefile:
clean:
rm -f testdata/*_thumb.*
创建者提到了未记录的zlib依赖项。它们都已安装:
zlib1g is already the newest version (1:1.2.8.dfsg-2ubuntu4.1).
zlib1g-dev is already the newest version (1:1.2.8.dfsg-2ubuntu4.1).
-
ubuntu@root:~$ ls -F -sh /lib/x86_64-linux-gnu/libz.*
0 /lib/x86_64-linux-gnu/libz.so.1@ 104K /lib/x86_64-linux-gnu/libz.so.1.2.8
这是完整的安装过程:
ubuntu@root:~$ go get -u -v -x github.com/bakape/thumbnailer
cd /home/ubuntu/go/src/github.com/bakape/thumbnailer
git config remote.origin.url
github.com/bakape/thumbnailer (download)
cd /home/ubuntu/go/src/github.com/bakape/thumbnailer
git pull --ff-only
cd /home/ubuntu/go/src/github.com/bakape/thumbnailer
git submodule update --init --recursive
cd /home/ubuntu/go/src/github.com/bakape/thumbnailer
git show-ref
cd /home/ubuntu/go/src/github.com/bakape/thumbnailer
git submodule update --init --recursive
WORK=/tmp/go-build312713059
github.com/bakape/thumbnailer
mkdir -p $WORK/github.com/bakape/thumbnailer/_obj/
mkdir -p $WORK/github.com/bakape/
cd /home/ubuntu/go/src/github.com/bakape/thumbnailer
pkg-config --cflags libavcodec libavutil libavformat GraphicsMagick++ libavcodec libavutil libavformat libswscale
pkg-config --libs libavcodec libavutil libavformat GraphicsMagick++ libavcodec libavutil libavformat libswscale
CGO_LDFLAGS="-g" "-O2" "-lm" "-L/usr/local/lib" "-lGraphicsMagick++" "-lGraphicsMagick" "-lavcodec" "-lavutil" "-lavformat" "-lswscale" /usr/local/go/pkg/tool/linux_amd64/cgo -objdir $WORK/github.com/bakape/thumbnailer/_obj/ -importpath github.com/bakape/thumbnailer -- -I/usr/local/include/GraphicsMagick -I/usr/include/x86_64-linux-gnu -I $WORK/github.com/bakape/thumbnailer/_obj/ -g -O2 -I/home/ubuntu/go/src/github.com/bakape/thumbnailer/libimagequant -std=c11 -std=c11 -O3 -D_POSIX_C_SOURCE -std=c11 audio.go buf.go build_flags_gpl.go ffmpeg.go meta.go thumbnailer.go video.go
cd $WORK
gcc -fdebug-prefix-map=a=b -c trivial.c
gcc -gno-record-gcc-switches -c trivial.c
cd $WORK/github.com/bakape/thumbnailer/_obj
gcc -I /home/ubuntu/go/src/github.com/bakape/thumbnailer -fPIC -m64 -pthread -fmessage-length=0 -fdebug-prefix-map=$WORK=/tmp/go-build -gno-record-gcc-switches -I/usr/local/include/GraphicsMagick -I/usr/include/x86_64-linux-gnu -I ./ -g -O2 -I/home/ubuntu/go/src/github.com/bakape/thumbnailer/libimagequant -std=c11 -std=c11 -O3 -D_POSIX_C_SOURCE -std=c11 -o ./_cgo_export.o -c _cgo_export.c
gcc -I /home/ubuntu/go/src/github.com/bakape/thumbnailer -fPIC -m64 -pthread -fmessage-length=0 -fdebug-prefix-map=$WORK=/tmp/go-build -gno-record-gcc-switches -I/usr/local/include/GraphicsMagick -I/usr/include/x86_64-linux-gnu -I ./ -g -O2 -I/home/ubuntu/go/src/github.com/bakape/thumbnailer/libimagequant -std=c11 -std=c11 -O3 -D_POSIX_C_SOURCE -std=c11 -o ./audio.cgo2.o -c audio.cgo2.c
gcc -I /home/ubuntu/go/src/github.com/bakape/thumbnailer -fPIC -m64 -pthread -fmessage-length=0 -fdebug-prefix-map=$WORK=/tmp/go-build -gno-record-gcc-switches -I/usr/local/include/GraphicsMagick -I/usr/include/x86_64-linux-gnu -I ./ -g -O2 -I/home/ubuntu/go/src/github.com/bakape/thumbnailer/libimagequant -std=c11 -std=c11 -O3 -D_POSIX_C_SOURCE -std=c11 -o ./buf.cgo2.o -c buf.cgo2.c
gcc -I /home/ubuntu/go/src/github.com/bakape/thumbnailer -fPIC -m64 -pthread -fmessage-length=0 -fdebug-prefix-map=$WORK=/tmp/go-build -gno-record-gcc-switches -I/usr/local/include/GraphicsMagick -I/usr/include/x86_64-linux-gnu -I ./ -g -O2 -I/home/ubuntu/go/src/github.com/bakape/thumbnailer/libimagequant -std=c11 -std=c11 -O3 -D_POSIX_C_SOURCE -std=c11 -o ./build_flags_gpl.cgo2.o -c build_flags_gpl.cgo2.c
gcc -I /home/ubuntu/go/src/github.com/bakape/thumbnailer -fPIC -m64 -pthread -fmessage-length=0 -fdebug-prefix-map=$WORK=/tmp/go-build -gno-record-gcc-switches -I/usr/local/include/GraphicsMagick -I/usr/include/x86_64-linux-gnu -I ./ -g -O2 -I/home/ubuntu/go/src/github.com/bakape/thumbnailer/libimagequant -std=c11 -std=c11 -O3 -D_POSIX_C_SOURCE -std=c11 -o ./ffmpeg.cgo2.o -c ffmpeg.cgo2.c
gcc -I /home/ubuntu/go/src/github.com/bakape/thumbnailer -fPIC -m64 -pthread -fmessage-length=0 -fdebug-prefix-map=$WORK=/tmp/go-build -gno-record-gcc-switches -I/usr/local/include/GraphicsMagick -I/usr/include/x86_64-linux-gnu -I ./ -g -O2 -I/home/ubuntu/go/src/github.com/bakape/thumbnailer/libimagequant -std=c11 -std=c11 -O3 -D_POSIX_C_SOURCE -std=c11 -o ./meta.cgo2.o -c meta.cgo2.c
gcc -I /home/ubuntu/go/src/github.com/bakape/thumbnailer -fPIC -m64 -pthread -fmessage-length=0 -fdebug-prefix-map=$WORK=/tmp/go-build -gno-record-gcc-switches -I/usr/local/include/GraphicsMagick -I/usr/include/x86_64-linux-gnu -I ./ -g -O2 -I/home/ubuntu/go/src/github.com/bakape/thumbnailer/libimagequant -std=c11 -std=c11 -O3 -D_POSIX_C_SOURCE -std=c11 -o ./thumbnailer.cgo2.o -c thumbnailer.cgo2.c
gcc -I /home/ubuntu/go/src/github.com/bakape/thumbnailer -fPIC -m64 -pthread -fmessage-length=0 -fdebug-prefix-map=$WORK=/tmp/go-build -gno-record-gcc-switches -I/usr/local/include/GraphicsMagick -I/usr/include/x86_64-linux-gnu -I ./ -g -O2 -I/home/ubuntu/go/src/github.com/bakape/thumbnailer/libimagequant -std=c11 -std=c11 -O3 -D_POSIX_C_SOURCE -std=c11 -o ./video.cgo2.o -c video.cgo2.c
cd /home/ubuntu/go/src/github.com/bakape/thumbnailer
gcc -I . -fPIC -m64 -pthread -fmessage-length=0 -fdebug-prefix-map=$WORK=/tmp/go-build -gno-record-gcc-switches -I/usr/local/include/GraphicsMagick -I/usr/include/x86_64-linux-gnu -I $WORK/github.com/bakape/thumbnailer/_obj/ -g -O2 -I/home/ubuntu/go/src/github.com/bakape/thumbnailer/libimagequant -std=c11 -std=c11 -O3 -D_POSIX_C_SOURCE -std=c11 -o $WORK/github.com/bakape/thumbnailer/_obj/audio.o -c audio.c
gcc -I . -fPIC -m64 -pthread -fmessage-length=0 -fdebug-prefix-map=$WORK=/tmp/go-build -gno-record-gcc-switches -I/usr/local/include/GraphicsMagick -I/usr/include/x86_64-linux-gnu -I $WORK/github.com/bakape/thumbnailer/_obj/ -g -O2 -I/home/ubuntu/go/src/github.com/bakape/thumbnailer/libimagequant -std=c11 -std=c11 -O3 -D_POSIX_C_SOURCE -std=c11 -o $WORK/github.com/bakape/thumbnailer/_obj/ffmpeg.o -c ffmpeg.c
gcc -I . -fPIC -m64 -pthread -fmessage-length=0 -fdebug-prefix-map=$WORK=/tmp/go-build -gno-record-gcc-switches -I/usr/local/include/GraphicsMagick -I/usr/include/x86_64-linux-gnu -I $WORK/github.com/bakape/thumbnailer/_obj/ -g -O2 -I/home/ubuntu/go/src/github.com/bakape/thumbnailer/libimagequant -std=c11 -std=c11 -O3 -D_POSIX_C_SOURCE -std=c11 -o $WORK/github.com/bakape/thumbnailer/_obj/init.o -c init.c
gcc -I . -fPIC -m64 -pthread -fmessage-length=0 -fdebug-prefix-map=$WORK=/tmp/go-build -gno-record-gcc-switches -I/usr/local/include/GraphicsMagick -I/usr/include/x86_64-linux-gnu -I $WORK/github.com/bakape/thumbnailer/_obj/ -g -O2 -I/home/ubuntu/go/src/github.com/bakape/thumbnailer/libimagequant -std=c11 -std=c11 -O3 -D_POSIX_C_SOURCE -std=c11 -o $WORK/github.com/bakape/thumbnailer/_obj/meta.o -c meta.c
gcc -I . -fPIC -m64 -pthread -fmessage-length=0 -fdebug-prefix-map=$WORK=/tmp/go-build -gno-record-gcc-switches -I/usr/local/include/GraphicsMagick -I/usr/include/x86_64-linux-gnu -I $WORK/github.com/bakape/thumbnailer/_obj/ -g -O2 -I/home/ubuntu/go/src/github.com/bakape/thumbnailer/libimagequant -std=c11 -std=c11 -O3 -D_POSIX_C_SOURCE -std=c11 -o $WORK/github.com/bakape/thumbnailer/_obj/video.o -c video.c
g++ -I . -fPIC -m64 -pthread -fmessage-length=0 -fdebug-prefix-map=$WORK=/tmp/go-build -gno-record-gcc-switches -I/usr/local/include/GraphicsMagick -I/usr/include/x86_64-linux-gnu -I $WORK/github.com/bakape/thumbnailer/_obj/ -g -O2 -I/home/ubuntu/go/src/github.com/bakape/thumbnailer/libimagequant -I/home/ubuntu/go/src/github.com/bakape/thumbnailer/lodepng -std=c++17 -O3 -o $WORK/github.com/bakape/thumbnailer/_obj/compress_png.cc.o -c compress_png.cc
g++ -I . -fPIC -m64 -pthread -fmessage-length=0 -fdebug-prefix-map=$WORK=/tmp/go-build -gno-record-gcc-switches -I/usr/local/include/GraphicsMagick -I/usr/include/x86_64-linux-gnu -I $WORK/github.com/bakape/thumbnailer/_obj/ -g -O2 -I/home/ubuntu/go/src/github.com/bakape/thumbnailer/libimagequant -I/home/ubuntu/go/src/github.com/bakape/thumbnailer/lodepng -std=c++17 -O3 -o $WORK/github.com/bakape/thumbnailer/_obj/thumbnailer.cc.o -c thumbnailer.cc
g++ -I . -fPIC -m64 -pthread -fmessage-length=0 -fdebug-prefix-map=$WORK=/tmp/go-build -gno-record-gcc-switches -I/usr/local/include/GraphicsMagick -I/usr/include/x86_64-linux-gnu -I $WORK/github.com/bakape/thumbnailer/_obj/ -g -O2 -I/home/ubuntu/go/src/github.com/bakape/thumbnailer/libimagequant -I/home/ubuntu/go/src/github.com/bakape/thumbnailer/lodepng -std=c++17 -O3 -o $WORK/github.com/bakape/thumbnailer/_obj/util.cc.o -c util.cc
cd $WORK/github.com/bakape/thumbnailer/_obj
gcc -I /home/ubuntu/go/src/github.com/bakape/thumbnailer -fPIC -m64 -pthread -fmessage-length=0 -fdebug-prefix-map=$WORK=/tmp/go-build -gno-record-gcc-switches -I/usr/local/include/GraphicsMagick -I/usr/include/x86_64-linux-gnu -I ./ -g -O2 -I/home/ubuntu/go/src/github.com/bakape/thumbnailer/libimagequant -std=c11 -std=c11 -O3 -D_POSIX_C_SOURCE -std=c11 -o ./_cgo_main.o -c _cgo_main.c
cd /home/ubuntu/go/src/github.com/bakape/thumbnailer
g++ -I . -fPIC -m64 -pthread -fmessage-length=0 -fdebug-prefix-map=$WORK=/tmp/go-build -gno-record-gcc-switches -o $WORK/github.com/bakape/thumbnailer/_obj/_cgo_.o $WORK/github.com/bakape/thumbnailer/_obj/_cgo_main.o $WORK/github.com/bakape/thumbnailer/_obj/_cgo_export.o $WORK/github.com/bakape/thumbnailer/_obj/audio.cgo2.o $WORK/github.com/bakape/thumbnailer/_obj/buf.cgo2.o $WORK/github.com/bakape/thumbnailer/_obj/build_flags_gpl.cgo2.o $WORK/github.com/bakape/thumbnailer/_obj/ffmpeg.cgo2.o $WORK/github.com/bakape/thumbnailer/_obj/meta.cgo2.o $WORK/github.com/bakape/thumbnailer/_obj/thumbnailer.cgo2.o $WORK/github.com/bakape/thumbnailer/_obj/video.cgo2.o $WORK/github.com/bakape/thumbnailer/_obj/audio.o $WORK/github.com/bakape/thumbnailer/_obj/ffmpeg.o $WORK/github.com/bakape/thumbnailer/_obj/init.o $WORK/github.com/bakape/thumbnailer/_obj/meta.o $WORK/github.com/bakape/thumbnailer/_obj/video.o $WORK/github.com/bakape/thumbnailer/_obj/compress_png.cc.o $WORK/github.com/bakape/thumbnailer/_obj/thumbnailer.cc.o $WORK/github.com/bakape/thumbnailer/_obj/util.cc.o -g -O2 -lm -L/usr/local/lib -lGraphicsMagick++ -lGraphicsMagick -lavcodec -lavutil -lavformat -lswscale
# github.com/bakape/thumbnailer
/usr/bin/ld: /usr/local/lib/libGraphicsMagick.a(magick_libGraphicsMagick_la-blob.o): undefined reference to symbol 'gzclose'
//lib/x86_64-linux-gnu/libz.so.1: error adding symbols: DSO missing from command line
collect2: error: ld returned 1 exit status
答案 0 :(得分:1)
您构建了本地静态GraphicsMagick,但未正确配置它。最好的办法是使用以下命令删除当前的GraphicsMagick:
sudo make uninstall
在GraphicsMagick文件夹中。
之后,只需使用以下命令安装GraphicsMagick:
sudo apt-get install graphicsmagick
所有库链接都将由“高级打包工具”自动处理。