Skip to content
This repository has been archived by the owner on Jul 4, 2023. It is now read-only.

Leptonica build fail (in process of installing Tesseract OCR engine) #18135

Closed
aktau opened this issue Feb 28, 2013 · 14 comments
Closed

Leptonica build fail (in process of installing Tesseract OCR engine) #18135

aktau opened this issue Feb 28, 2013 · 14 comments

Comments

@aktau
Copy link
Contributor

aktau commented Feb 28, 2013

Problem

It appears that a png.h file was not found. How would I go about remediating that?

brew doctor and brew --config: https://gist.github.com/Aktau/5055678
brew install -v tesseract: https://gist.github.com/Aktau/5055687

@aktau
Copy link
Contributor Author

aktau commented Feb 28, 2013

I've been trying to figure this out. If I use brew deps leptonica I only get jpeg. Even though in the formula it says that it depends on :libpng. Is something wrong with that symbolic reference?

By the way, how does homebrew make its environment for including header files? I see lines like this scrolling by:

libtool: compile:  cc -DHAVE_CONFIG_H -I. -I.. -g -O2 -c bilinear.c -o bilinear.o >/dev/null 2>&1

And I wonder how that could possibly work when its only looking for header files in the current directory . and the parent directory ... Is that something that homebrew decides?

The build doesn't complain about lacking a jpeglib.h but I can't find it either when I issue brew install -vd leptonica. Where is it stored? How is it linked in? Maybe this can help me trace the problem better...

Thanks in advance for the assistance!

@jacknagel
Copy link
Contributor

Even though in the formula it says that it depends on :libpng. Is something wrong with that symbolic reference?

Nope, that's expected; on 10.7 the symbol :libpng resolves to X11 (which provides libpng) rather than the libpng formula.

And I wonder how that could possibly work when its only looking for header files in the current directory . and the parent directory ... Is that something that homebrew decides?

(a) system header directories are always searched by default and (b) superenv intercepts calls to cc and adds the appropriate flags before passing them on to the real compiler.

@aktau aktau closed this as completed Feb 28, 2013
@aktau aktau reopened this Feb 28, 2013
@aktau
Copy link
Contributor Author

aktau commented Feb 28, 2013

Nope, that's expected; on 10.7 the symbol :libpng resolves to X11 (which provides libpng) rather than the libpng formula.

It seems that on my system at least, there is no such png.h file except inside of Xcode. Is it maybe because I don't have command line tools installed (I like to keep clean)? Is it maybe because I don't have Xquartz or any X11 formula installed with homebrew? If that's the case shouldn't homebrew autorequire X11 when it encounter :libpng?

EDIT: The path of the only png.h I found on my filesystem:

/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.7.sdk/usr/X11/include/libpng15/png.h

(a) system header directories are always searched by default and (b) superenv intercepts calls to cc and adds the appropriate flags before passing them on to the real compiler.

I see, it seems I will have to learn a bit more about this superenv thing. Is there any way to debug the statements it generates? Also, is there a list of which paths are considered system paths? Does homebrew decide this or the compiler toolchain?

@aktau
Copy link
Contributor Author

aktau commented Mar 1, 2013

@jacknagel : At any rate it seems that the development files for libpng are not (by default) installed on my 10.7. Shouldn't homebrew look inside the XCode sdk as well for files? Maybe that got left out with the switch to the superenv? Maybe the testing only focused on 10.8 (where I get the idea that another way is used to add :libpng

@mistydemeo
Copy link
Member

@aktau On 10.7, png.h should be in /usr/X11/include/libpng15/png.h

@aktau
Copy link
Contributor Author

aktau commented Mar 1, 2013

@mistydemeo That's very odd, I had already checked for the presence of a png.h but the only one I found was the one in the Xcode.app folder that I showed in my earlier post. Here's the contents of my /usr/X11/include folder:

➜  include  pwd
/usr/X11/include
➜  include  ls
X11
➜  include  ls -R
X11

./X11:
bitmaps

./X11/bitmaps:
1x1          RotateLeft   cntr_ptrmsk  flipped_gray icon         mailfullmsk  plaid        target       xlogo11
2x2          RotateRight  cross_weave  gray         keyboard16   mensetmanus  rdblarrow    terminal     xlogo16
Dashes       Term         dimple1      gray1        ldblarrow    menu10       right_ptr    tie_fighter  xlogo32
Down         Up           dimple3      gray3        left_ptr     menu12       right_ptrmsk vlines2      xlogo64
Excl         black        dot          grid16       left_ptrmsk  menu16       root_weave   vlines3      xsnow
FlipHoriz    black6       dropbar7     grid2        letters      menu6        scales       weird_size
FlipVert     box6         dropbar8     grid4        light_gray   menu8        sipb         wide_weave
Fold         boxes        escherknot   grid8        mailempty    noletters    star         wingdogs
Left         calculator   flagdown     hlines2      mailemptymsk opendot      starMask     woman
Right        cntr_ptr     flagup       hlines3      mailfull     opendotMask  stipple      xfd_icon

Any idea on what could've gone wrong with my install? I'm finding very little information about this on the web. Could I try to reinstall X11? Thing is I've heard that apple no longer supports it and wants people to go for xquartz...

@aktau
Copy link
Contributor Author

aktau commented Mar 1, 2013

I'm having the idea that maybe the /usr/X11/include directory only includes the right files if at some point an older version of Xcode existed on the system which installed its files all over the system. The earliest Xcode I ever installed was 4.4, which was already an .app.

@foolip
Copy link

foolip commented Mar 21, 2013

I'm running Mac OS X 10.6.8 and was having the same problem. Xcode can't be installed via the app store, so I followed http://blog.strug.de/2011/09/homebrew-without-xcode-save-15-gb/

png.h was nowhere to be found, so I did brew install libpng followed by brew edit leptonica:

   def install
+    ENV["CPPFLAGS"] = "-I/usr/local/opt/libpng/include"
+    ENV["LDFLAGS"] = "-L/usr/local/opt/libpng/lib"
     system "./configure", "--disable-dependency-tracking",
                           "--prefix=#{prefix}"
     system "make install"

This fixed the problem for me.

@aktau
Copy link
Contributor Author

aktau commented Mar 21, 2013

And I just installed the command-line tools, which fixed it for me.

Personally, I think that it might be advantageous for homebrew to look for the X11 header files in the XCode bundle because I prefer not to install the commandline tools. Should I open another bug or...?

@adamv
Copy link
Contributor

adamv commented Mar 21, 2013

@aktau open a pull request

@mistydemeo
Copy link
Member

@foolip If you install the tools that way, you don't get X11, which is where we source libpng on 10.6.8. You should install X11 or XQuartz.

@MikeMcQuaid
Copy link
Member

@mistydemeo We should probably add a doctor check for those tools at this point.

@mistydemeo
Copy link
Member

@MikeMcQuaid Agreed, but the unfortunate thing is I'm not sure if there's a single identifying characteristic we could use to detect them.

Ping @kennethreitz?

@adamv
Copy link
Contributor

adamv commented Apr 17, 2013

Closing since the original poster's problem was solved in one way or another.

@adamv adamv closed this as completed Apr 17, 2013
@Homebrew Homebrew locked and limited conversation to collaborators Feb 16, 2016
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

6 participants