chai2010 / guetzli-go

Guetzli perceptual JPEG encoder for Go (Zero Dependencies).
https://godoc.org/github.com/chai2010/guetzli-go
85 stars 7 forks source link

How to compile on Ubuntu? #3

Closed abcfy2 closed 7 years ago

abcfy2 commented 7 years ago

I can't compile this code on ubuntu 16.04. How to ?

$ go get github.com/chai2010/guetzli-go
# github.com/chai2010/guetzli-go
go/src/github.com/chai2010/guetzli-go/capi.cc: In function ‘void rgbToRGBVector(std::vector<unsigned char>*, const uint8_t*, int, int, int)’:
go/src/github.com/chai2010/guetzli-go/capi.cc:58:39: error: ‘memcpy’ was not declared in this scope
   memcpy(rgb->data(), pix, rgb->size());
                                       ^
go/src/github.com/chai2010/guetzli-go/capi.cc:62:43: error: ‘memcpy’ was not declared in this scope
   memcpy(&(*rgb)[i*w*3], pix+i*stride, w*3);
                                           ^

go version: go version go1.8 linux/amd64

gcc version:

Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-linux-gnu/5/lto-wrapper
Target: x86_64-linux-gnu
Configured with: ../src/configure -v --with-pkgversion='Ubuntu 5.4.0-6ubuntu1~16.04.4' --with-bugurl=file:///usr/share/doc/gcc-5/README.Bugs --enable-languages=c,ada,c++,java,go,d,fortran,objc,obj-c++ --prefix=/usr --program-suffix=-5 --enable-shared --enable-linker-build-id --libexecdir=/usr/lib --without-included-gettext --enable-threads=posix --libdir=/usr/lib --enable-nls --with-sysroot=/ --enable-clocale=gnu --enable-libstdcxx-debug --enable-libstdcxx-time=yes --with-default-libstdcxx-abi=new --enable-gnu-unique-object --disable-vtable-verify --enable-libmpx --enable-plugin --with-system-zlib --disable-browser-plugin --enable-java-awt=gtk --enable-gtk-cairo --with-java-home=/usr/lib/jvm/java-1.5.0-gcj-5-amd64/jre --enable-java-home --with-jvm-root-dir=/usr/lib/jvm/java-1.5.0-gcj-5-amd64 --with-jvm-jar-dir=/usr/lib/jvm-exports/java-1.5.0-gcj-5-amd64 --with-arch-directory=amd64 --with-ecj-jar=/usr/share/java/eclipse-ecj.jar --enable-objc-gc --enable-multiarch --disable-werror --with-arch-32=i686 --with-abi=m64 --with-multilib-list=m32,m64,mx32 --enable-multilib --with-tune=generic --enable-checking=release --build=x86_64-linux-gnu --host=x86_64-linux-gnu --target=x86_64-linux-gnu
Thread model: posix
gcc version 5.4.0 20160609 (Ubuntu 5.4.0-6ubuntu1~16.04.4) 
chai2010 commented 7 years ago

the new commit, capi.cc add the <string.h> header for memcpy: https://github.com/chai2010/guetzli-go/commit/015096ec963d81cd19a45d241e272e141872be96

please try again. thanks

abcfy2 commented 7 years ago

Thanks, it works. But there's another warning:

# github.com/chai2010/guetzli-go
In file included from go/src/github.com/chai2010/guetzli-go/z_guetzli_processor.cc:5:0:
go/src/github.com/chai2010/guetzli-go/./internal/guetzli-1.0/guetzli/processor.cc:180:7: warning: ‘guetzli::QuantMatrixGenerator’ has a field ‘guetzli::QuantMatrixGenerator::quants_’ whose type uses the anonymous namespace
 class QuantMatrixGenerator {
       ^
chai2010 commented 7 years ago

you can try add the ldflag to the cgo.go's cgo comment:

#cgo linux LDFLAGS: -Wno-subobject-linkage

ps: it is not work on the windows(gcc version 5.1.0 (tdm64-1)). i don't know the reason.

patch are welcom!