google / guetzli

Perceptual JPEG encoder
Apache License 2.0
12.9k stars 976 forks source link

Building on OS X #39

Closed dalanmiller closed 7 years ago

dalanmiller commented 7 years ago
$ ~ brew list
... gflags libpng ... 
$ ~/git/guetzli make
==== Building guetzli (release) ====
guetzli.cc
guetzli/guetzli.cc:24:10: fatal error: 'gflags/gflags.h' file not found
#include "gflags/gflags.h"
         ^
1 error generated.
make[1]: *** [obj/Release/guetzli.o] Error 1
make: *** [guetzli] Error 2 

Anyone gotten this to work?

btnwtn commented 7 years ago

Try brew update && brew install libpng gflags.

dalanmiller commented 7 years ago
$ ~ brew update && brew install libpng gflags
Already up-to-date.
Warning: libpng-1.6.28 already installed
Warning: gflags-2.2.0 already installed
dalanmiller commented 7 years ago

I think it might be something to do with the way gflags is linked? I've done both brew unlink and brew link on it however.

kornelski commented 7 years ago
 brew unlink gflags && brew link gflags

doesn't help, because guetzli/bazel is not even trying to find where they are installed. It just assumes they'll be in the default include path or the current directory.

The build script has to use pkg-config --cflags gflags

error-0x29A commented 7 years ago

I downloaded and unpacked the archive and then CLI'd into the unpacked folder and ran make and it worked just fine. This is after doing brew update && brew install libpng gflags

The binary is in the bin folder and seems to have been built successfully.

Because I went into the directory itself, I assume that's why it worked for me, because its assumption of "current directory" was true in my particular case.

CliffsDover commented 7 years ago

Add path to headers and the libraries to guetzli.make will solve your problem. Because Homebrew will install headers and libraries to /usr/local/include and /usr/local/lib by default.

fkistner commented 7 years ago

See also: Homebrew/homebrew-core#11190 (seems to work fine for El Capitan and Sierra)

bcackerman commented 7 years ago

Someone's gotta make a simple app around this

kornelski commented 7 years ago

I'll be adding it to ImageOptim.

positlabs commented 7 years ago

Nice. I was just about to suggest that!

gcomstock commented 7 years ago

Thanks @pornel ! I'm excited to share this with our design team.

Pesthauch666 commented 7 years ago

BTW if someone is planning to built it with libpng and gflags installed via MacPorts you have to edit guetzli.make similar as CliffsDovers suggestion above. But for MacPorts it has to point to /opt/local/lib

When trying to built it with the necessary libs installed through MacPorts the build-process failed because the libs couldn't be found.

==== Building guetzli (release) ====
guetzli.cc
guetzli/guetzli.cc:25:10: fatal error: 'png.h' file not found
#include "png.h"
         ^
1 error generated.
make[1]: *** [obj/Release/guetzli.o] Error 1
make: *** [guetzli] Error 2

In both lines of guetzli.make beginning wie LIBS you have to add: -L/opt/local/lib like LIBS += -L/opt/local/lib -lpng -lgflags_nothreads -lz -lpthread

robryk commented 7 years ago

@Pesthauch666 Does MacPorts cause pkg-config to report correct paths?

Pesthauch666 commented 7 years ago

@robryk I'm not that familar with this tool (I'm still a rookie after all), but: pkg-config --libs libpng reports -L/opt/local/lib -lpng16