gographics / imagick

Go binding to ImageMagick's MagickWand C API
https://godoc.org/github.com/gographics/imagick/imagick
Other
1.75k stars 182 forks source link

static link #287

Closed bakeDong1 closed 1 year ago

bakeDong1 commented 1 year ago

os type: archlinux magick --version Version: ImageMagick 7.0.10-29 Q16 x86_64 2022-12-12 https://imagemagick.org Copyright: © 1999-2020 ImageMagick Studio LLC License: https://imagemagick.org/script/license.php Features: Cipher DPC HDRI OpenMP(4.5) Delegates (built-in): bzlib fftw fontconfig freetype gvc heic jng jp2 jpeg lcms lqr lzma openexr pangocairo png raqm tiff webp x xml zlib

export CGO_LDFLAGS="\
-Wl,-Bstatic \
            -L/usr/local/lib/libMagickWand-7.Q16HDRI.a   -L/usr/local/lib/libMagickCore-7.Q16HDRI.a \
            -L/usr/lib/Imath   -L/usr/lib/IlmThread -L/usr/lib/lcms2 -L/usr/lib/fontconfig -L/usr/lib/freetype -L/usr/lib/xml2 -L/usr/lib/glib-2.0 -L/usr/lib/png12 -L/usr/lib/bz2 -L/usr/lib/z -L/usr/lib/m  -L/usr/lib/jbig -L/usr/lib/tiff -L/usr/lib/jpeg -L/usr/lib/webp -L/usr/lib/lzma -L/usr/lib/fftw3 -L/usr/lib/bz2 -L/usr/lib/gomp \
-Wl,-Bdynamic"
export CGO_CFLAGS="-I/usr/local/include/ImageMagick-7 -fopenmp -DMAGICKCORE_HDRI_ENABLE=1 -DMAGICKCORE_QUANTUM_DEPTH=16 -L/usr/local/lib/libMagickWand-7.Q16HDRI.a -L/usr/local/lib/libMagickCore-7.Q16HDRI.a"
rm -rf $GOPATH/pkg/linux_amd64/gopkg.in/gographics/imagick.v3 && go clean -cache && go clean -modcache
go install -tags no_pkgconfig -x -v gopkg.in/gographics/imagick.v3/imagick

I was got error

gopkg.in/gographics/imagick.v3/imagick /usr/bin/ld: $WORK/b001/_x002.o: in function_cgo_83eb6e58db04_Cfunc_GetAffineMatrix': affine_matrix.cgo2.c:(.text+0x55): undefined reference to GetAffineMatrix' /usr/bin/ld: $WORK/b001/_x012.o: in function_cgo_83eb6e58db04_Cfunc_ConvertHSLToRGB': conversions.cgo2.c:(.text+0x8c): undefined reference to ConvertHSLToRGB' /usr/bin/ld: $WORK/b001/_x012.o: in function_cgo_83eb6e58db04_Cfunc_ConvertRGBToHSL': conversions.cgo2.c:(.text+0xe9): undefined reference to ConvertRGBToHSL' /usr/bin/ld: $WORK/b001/_x017.o: in function_cgo_83eb6e58db04_Cfunc_AcquireDrawInfo': draw_info.cgo2.c:(.text+0x54): undefined reference to AcquireDrawInfo' /usr/bin/ld: $WORK/b001/_x018.o: in function_cgo_83eb6e58db04_Cfunc_ClearDrawingWand': drawing_wand.cgo2.c:(.text+0x55): undefined reference to ClearDrawingWand' /usr/bin/ld: $WORK/b001/_x018.o: in function_cgo_83eb6e58db04_Cfunc_CloneDrawingWand': drawing_wand.cgo2.c:(.text+0x84): undefined reference to CloneDrawingWand' /usr/bin/ld: $WORK/b001/_x018.o: in function_cgo_83eb6e58db04_Cfunc_DestroyDrawingWand': drawing_wand.cgo2.c:(.text+0xd0): undefined reference to DestroyDrawingWand' /usr/bin/ld: $WORK/b001/_x018.o: in function_cgo_83eb6e58db04_Cfunc_DrawAffine': drawing_wand.cgo2.c:(.text+0x11e): undefined reference to DrawAffine' /usr/bin/ld: $WORK/b001/_x018.o: in function_cgo_83eb6e58db04_Cfunc_DrawAlpha': drawing_wand.cgo2.c:(.text+0x167): undefined reference to DrawAlpha' /usr/bin/ld: $WORK/b001/_x018.o: in function_cgo_83eb6e58db04_Cfunc_DrawAnnotation': drawing_wand.cgo2.c:(.text+0x1b2): undefined reference to DrawAnnotation' /usr/bin/ld: $WORK/b001/_x018.o: in function_cgo_83eb6e58db04_Cfunc_DrawArc': drawing_wand.cgo2.c:(.text+0x226): undefined reference to DrawArc' /usr/bin/ld: $WORK/b001/_x018.o: in function_cgo_83eb6e58db04_Cfunc_DrawBezier': drawing_wand.cgo2.c:(.text+0x25f): undefined reference to DrawBezier' /usr/bin/ld: $WORK/b001/_x018.o: in function_cgo_83eb6e58db04_Cfunc_DrawCircle': drawing_wand.cgo2.c:(.text+0x2b9): undefined reference to DrawCircle' /usr/bin/ld: $WORK/b001/_x018.o: in function_cgo_83eb6e58db04_Cfunc_DrawColor': drawing_wand.cgo2.c:(.text+0x302): undefined reference to DrawColor'

justinfx commented 1 year ago

Hi,

Your linker and compile flags are all over the place.

For the linker flags, "-L" provides a path to a directory containing libraries but you are passing it a path to a static lib. Try this

export CGO_LDFLAGS="\ 
-Wl,-Bstatic \          
-L/usr/local/lib \
-lMagickWand-7.Q16HDRI -lMagickCore-7.Q16HDRI \             
... \
-Wl,-Bdynamic" 

And I am not sure what all the other paths are to the rest of the link dependencies. Are each one of those directories containing the needed .a files? If so, you will have to also add -l<name> for each.

As for your cflags, you don't need to pass linker -L paths.

bakeDong1 commented 1 year ago

thanks! i will check it