Undefined reference to symbol 'gzclose' error when getting library - go

Multi tool use
Multi tool use


Undefined reference to symbol 'gzclose' error when getting library - go



When I try to get one of my libraries on my linux machine with the following command:


go get -t github.com/bakape/thumbnailer



then I get this error message:



-# github.com/bakape/thumbnailer /usr/bin/ld: /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



People who encountered this error said this is a linking error and they fixed it by adding some additional tags in the Makefile. I did this too, but this did not work for me. I tried so many solutions, but nothing seems to work for me.



I'm using the following library:
https://github.com/bakape/thumbnailer



This is the Makefile:


clean:
rm -f testdata/*_thumb.*



The creator mentioned undocumented zlib dependencies. All of them are installed:


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



Here is the full installation process:


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





is this a duplicate of stackoverflow.com/questions/43603178/… ? Or rather stackoverflow.com/questions/9700414/… or stackoverflow.com/questions/8259441/… or stackoverflow.com/questions/41898192/…
– Richard Chambers
Jul 1 at 18:28






"People who encountered this error said this is a linking error and they fixed it by adding: x. I tried this too but this did not work for me"
– dfi
Jul 1 at 18:43





What these postings seem to say is that it is a link order issue, the order of the libraries specified. And they mention -lz and not -lm. And since there appears to be an issue with your makefile, do you think it would be a good idea to include a copy of your makefile in your posting?or stackoverflow.com/questions/13149515/…
– Richard Chambers
Jul 1 at 19:08



-lz


-lm


makefile


makefile





I have provided you a list of stackoverflow postings of this exact same issue and they all seem to agree on what is to be done. I have also asked for a copy of your makefile to be added to your posting. Finally this issue, at the bottom, indicates there may be an undocumented dependency on the zlib dev package github.com/bakape/thumbnailer/issues/26
– Richard Chambers
Jul 1 at 19:37


makefile





Yes, I know, the newest version of zlib is already installed. I added the Makefile to the initial question. Thanks for trying to help.
– dfi
Jul 1 at 19:40





1 Answer
1



You built a local static GraphicsMagick and you did not configure it properly. The best thing for you is to remove the current GraphicsMagick by using the command:


sudo make uninstall



in the GraphicsMagick folder.



After that, simply install GraphicsMagick using the command:


sudo apt-get install graphicsmagick



All library links will be handled automatically by the Advanced Packaging Tool.





It's working perfectly now, thank you so much !
– dfi
2 days ago





You are welcome!
– thelearner
2 days ago






By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

7v76SZ 3P1dehcOb7Gwf,g0nCICjs,s61giBpIoc4PqNrotabbxmShwFxf8,wWVrYi9nyxsg
j,W3P sD,nZXzZS5SRwr1BJKopnH rGMySgV5w Ytr3mxeeHaeVi,MWB1TKmPpF5o6MlYLgpFn,xs3wa93

Popular posts from this blog

Rothschild family

Cinema of Italy