首页 > 代码库 > ubuntu12.04不支持gobinding

ubuntu12.04不支持gobinding

尝试用gobinding去编写imagemagick

本人采用的系统是ubutu12.04,先前因为系统apt安装缺少库文件,我采用的是tar下载make install安装,这里给一个已经加入库文件的tar包

http://download.csdn.net/detail/u010026901/7642329

OK,接着去看官方的文档和github,按顺序执行

Ubuntu / Debian

sudo apt-get install libmagickwand-dev

Common

Check if pkg-config is able to find the right ImageMagick include and libs:

pkg-config --cflags --libs MagickWand

Then go get it:

go get github.com/gographics/imagick/imagick  //默认安装在第一个gopath的文件夹下
我就简单写了个demo

package main


import (
"fmt"
"github.com/gographics/imagick/imagick"
)


func main() {
imagick.Initialize()
defer imagick.Terminate()
mw := imagick.NewMagickWand()
defer mw.Destroy()
mw.ReadImage("/home/qboxtest/qbox/image/fop_ncgo/src/qbox.us/fop/imgave/samples/sample.jpg")


height := int(mw.GetImageHeight())
width := int(mw.GetImageWidth())
println(height, width)
pw := imagick.NewPixelWand()
defer pw.Destroy()
pw=mw.GetImagePixelColor(2, 2)//恭喜这里出问题,后查原因,应该是和tar包提供的库文件有冲突,编译没问题,执行歇菜
fmt.Println("xxxx", pw)


r := pw.GetRed()
g := pw.GetGreen()
b := pw.GetBlue()
a := pw.GetAlpha()
println("xxxxxxx", r, g, b, a)


rgb := int(10)<<16 | int(11)<<8 | int(12)
fmt.Printf("0x%06x", rgb)
}

接下来我卸载了自身安装的imagemagick,重新走流程,不管是否用apt安装imagemagick,始终报错

# command-line-arguments
/usr/bin/ld: cannot find -lMagickWand-6.Q16
/usr/bin/ld: cannot find -lMagickCore-6.Q16
collect2: ld returned 1 exit status

在usr/lib和usr/local/lib都找不到对应的库文件,也没有可安装的路子,也查找不到

qboxtest@xxx:~/Desktop$ apt-cache search ImageMagic*
groff - GNU troff text-formatting system
imagemagick - image manipulation programs
imagemagick-common - image manipulation programs -- infrastructure
imagemagick-dbg - debugging symbols for ImageMagick
imagemagick-doc - document files of ImageMagick
inkscape - vector-based drawing program
libmagick++-dev - object-oriented C++ interface to ImageMagick - development files
libmagick++4 - object-oriented C++ interface to ImageMagick
libmagickcore4 - low-level image manipulation library
libmagickwand4 - image manipulation library
libreoffice - office productivity suite
perlmagick - Perl interface to the ImageMagick graphics routines
tex4ht - LaTeX and TeX for Hypertext (HTML) - executables
tex4ht-common - LaTeX and TeX for Hypertext (HTML) - support files
ctioga - command-line plotting utility
drupal6-mod-imageapi - imageapi module for Drupal 6
drupal6-mod-imagecache - imagecache module for Drupal 6

用dpkg -S Magic*查看,发现ubuntu12.04自带的库是6.6.9版本的,但是gobinding要求6.8以上

qboxtest@xxx:~/Desktop$  dpkg -S Magic*
libmagickcore-dev: /usr/lib/libMagickCore.a
libmagickcore4: /usr/lib/ImageMagick-6.6.9/modules-Q16/coders/gradient.so
libmagickcore-dev: /usr/include/ImageMagick/magick/random_.h
libmagickcore4: /usr/lib/ImageMagick-6.6.9/modules-Q16/coders/html.la
libmagickcore4: /usr/lib/ImageMagick-6.6.9/modules-Q16/coders/ps2.la
libmagickcore-dev: /usr/include/ImageMagick/magick/memory_.h
libmagickcore4: /usr/lib/ImageMagick-6.6.9/modules-Q16/coders/sun.so
libmagickcore4: /usr/share/ImageMagick-6.6.9/english.xml
libmagickcore4: /usr/lib/ImageMagick-6.6.9/modules-Q16/coders/ipl.la
libmagickcore-dev: /usr/include/ImageMagick/magick/policy.h
libmagickcore4: /usr/lib/ImageMagick-6.6.9/modules-Q16/coders/pcx.la
imagemagick-common: /etc/ImageMagick/log.xml
libmagickcore4: /usr/lib/ImageMagick-6.6.9/modules-Q16/coders/sct.la
libmagickcore4: /usr/lib/ImageMagick-6.6.9/modules-Q16/coders/stegano.so
libmagickcore4: /usr/lib/ImageMagick-6.6.9/modules-Q16/coders/sgi.so
libmagickwand-dev: /usr/include/ImageMagick/wand/conjure.h
libmagickcore4: /usr/lib/ImageMagick-6.6.9/modules-Q16/coders/pix.la
libmagickcore4: /usr/lib/ImageMagick-6.6.9/modules-Q16/coders/art.so

这时候再去编译的时候发现编译不过

# github.com/gographics/imagick/imagick
37: error: ‘FlattenAlphaChannel‘ undeclared (first use in this function)
37: error: ‘RemoveAlphaChannel‘ undeclared (first use in this function)

ubuntu12.04不支持gobinding