twelve17 / openalpr-ios

Xcode Framework for the openalpr library
GNU General Public License v3.0
116 stars 35 forks source link

Leptonica not found when executing the build script #9

Closed JeanAzzopardi closed 8 years ago

JeanAzzopardi commented 8 years ago

Hi, thanks for updating the repository! I've tried to run the build script, however I have the following issue:

 ~/Testing/PersonalTests/openalpr-ios   master  ./bin/build_frameworks.rb 
options: {}
Package opencv2 is already installed. Skipping build.
Package leptonica is already installed. Skipping build.
Building tesseract for armv7 from /Users/jeaz/Testing/PersonalTests/openalpr-ios/work/tesseract-3.03
make: *** No rule to make target `clean'.  Stop.
make: *** No rule to make target `distclean'.  Stop.
configure: WARNING: using cross tools not prefixed with host triplet
configure: error: leptonica not found
/Users/jeaz/Testing/PersonalTests/openalpr-ios/lib/alpr/utils.rb:44:in `execute': Child returned: pid 11910 exit 1 (RuntimeError)
    from /Users/jeaz/Testing/PersonalTests/openalpr-ios/lib/alpr/utils.rb:74:in `log_execute'
    from /Users/jeaz/Testing/PersonalTests/openalpr-ios/lib/alpr/package/automake.rb:147:in `do_autoconf_build'
    from /Users/jeaz/Testing/PersonalTests/openalpr-ios/lib/alpr/package/automake.rb:58:in `build_arch'
    from /Users/jeaz/Testing/PersonalTests/openalpr-ios/lib/alpr/package/base.rb:53:in `block in install'
    from /Users/jeaz/Testing/PersonalTests/openalpr-ios/lib/alpr/package/base.rb:52:in `each'
    from /Users/jeaz/Testing/PersonalTests/openalpr-ios/lib/alpr/package/base.rb:52:in `install'
    from ./bin/build_frameworks.rb:54:in `<main>'

This is the last line from the build log:


All done.
To build the software now, do something like:

$ ./configure [--enable-debug] [...other options]
=======================================================================
Executing: SDKROOT='/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS9.1.sdk' CXX='/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/c++' CC='/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/cc' LD='/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ld' AS='/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/as' AR='/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ar' NM='/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/nm' RANLIB='/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ranlib' LDFLAGS='-L/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS9.1.sdk/usr/lib/ -L/Users/jeaz/Testing/PersonalTests/openalpr-ios/work/leptonica-thin-lib/iPhoneOS-armv7' CFLAGS='-arch armv7 -pipe -no-cpp-precomp -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS9.1.sdk -miphoneos-version-min=9.0 -I/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS9.1.sdk/usr/include/ -I/Users/jeaz/Testing/PersonalTests/openalpr-ios/output/leptonica.framework/Headers' CPPFLAGS='-arch armv7 -pipe -no-cpp-precomp -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS9.1.sdk -miphoneos-version-min=9.0 -I/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS9.1.sdk/usr/include/ -I/Users/jeaz/Testing/PersonalTests/openalpr-ios/output/leptonica.framework/Headers' CXXFLAGS='-arch armv7 -pipe -no-cpp-precomp -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS9.1.sdk -miphoneos-version-min=9.0 -I/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS9.1.sdk/usr/include/ -I/Users/jeaz/Testing/PersonalTests/openalpr-ios/output/leptonica.framework/Headers' PATH='/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin:/Users/jeaz/.rvm/gems/ruby-2.2.1/bin:/Users/jeaz/.rvm/gems/ruby-2.2.1@global/bin:/Users/jeaz/.rvm/rubies/ruby-2.2.1/bin:/Users/jeaz/.rvm/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin' BUILD_HOST_NAME='arm-apple-darwin7' ./configure --host=arm-apple-darwin7 --enable-shared=no && make -j12 2>&1
=======================================================================

Now, I've checked this folder: /Users/jeaz/Testing/PersonalTests/openalpr-ios/output/leptonica.framework/Headers and inside there is a folder called leptonica with the following files:

ls /Users/jeaz/Testing/PersonalTests/openalpr-ios/output/leptonica.framework/Headers/leptonica 
allheaders.h  bmf.h         freetype.h    list.h        recog.h
alltypes.h    bmp.h         gplot.h       morph.h       regutils.h
array.h       ccbord.h      heap.h        pix.h         stack.h
arrayaccess.h dewarp.h      imageio.h     ptra.h        sudoku.h
bbuffer.h     endianness.h  jbclass.h     queue.h       watershed.h
bilateral.h   environ.h     leptwin.h     readbarcode.h

Any idea what it could be please?

twelve17 commented 8 years ago

Hi @JeanAzzopardi,

Does this file exist?

/Users/jeaz/Testing/PersonalTests/openalpr-ios/output/leptonica.framework/leptonica

Also, is there anything in this folder?

/Users/jeaz/Testing/PersonalTests/openalpr-ios/work/leptonica-thin-lib/iPhoneOS-armv7

JeanAzzopardi commented 8 years ago

Hi,

Yes, the leptonica file exists:

ls -lah /Users/jeaz/Testing/PersonalTests/openalpr-ios/output/leptonica.framework
total 35912
drwxr-xr-x  6 jeaz  ---   204B Nov 11 18:28 .
drwxr-xr-x  5 jeaz  ---   170B Nov 11 18:28 ..
drwxr-xr-x  3 jeaz  ---   102B Nov 11 18:27 Headers
-rw-r--r--  1 jeaz  ---   580B Nov 11 18:28 Info.plist
-rw-r--r--  1 jeaz  ---    18M Nov 11 18:28 leptonica
lrwxr-xr-x  1 jeaz  ---     9B Nov 11 18:28 liblept.a -> leptonica

Also:

ls -la /Users/jeaz/Testing/PersonalTests/openalpr-ios/work/leptonica-thin-lib/iPhoneOS-armv7
total 6664
drwxr-xr-x  3 jeaz  ---      102 Nov 11 11:14 .
drwxr-xr-x  7 jeaz  ---      238 Nov 11 11:14 ..
-rw-r--r--  1 jeaz  ---  3409888 Nov 11 11:14 liblept.a
twelve17 commented 8 years ago

Hmm, that is odd. :)

Tesseract is complaining that the leptonica library is not there, but it seems to be. Do you mind attaching this log file?

/Users/jeaz/Testing/PersonalTests/openalpr-ios/work/tesseract-3.03/config.log

JeanAzzopardi commented 8 years ago

Ah, I found the issue, tesseract's configure script expects leptonica's location to be passed through an environment variable.

For now I've done a quick hack:

env = {
        'SDKROOT' => sdk_root,
        'CXX' => CXX,
        'CC' => CC,
        'LD' => LD,
        'AS' => AS,
        'AR' => AR,
        'NM' => NM,
        'RANLIB' => RANLIB,
        'LDFLAGS' => ldflags,
        'CFLAGS' => cflags,
        'CPPFLAGS' => cflags,
        'CXXFLAGS' => cflags,
        'PATH' => "#{XCODETOOLCHAIN}/usr/bin:#{ENV['PATH']}",
        'LIBLEPT_HEADERSDIR' => '/Users/jeanazzopardi/software/openalpr-ios/output/leptonica.framework/Headers'
      }

in automake.rb Using this method, tesseract is compiling as we speak.

twelve17 commented 8 years ago

Hi @JeanAzzopardi,

Usage of LIBLEPT_HEADERSDIR should not be required, as the ruby script passes a separate include directive in the CFLAGS, CPPFLAGS and CXXFLAGS with this same path. Here's the relevant part from the build.log line you included in the original comment:

-I/Users/jeaz/Testing/PersonalTests/openalpr-ios/output/leptonica.framework/Headers

I also noticed that the most recent comment above, the path is now /Users/jeanazzopardi/.... instead of /Users/jeaz. Could that maybe have contributed to the script not finding leptonica previously?

JeanAzzopardi commented 8 years ago

@twelve17 I'm on a different computer - that's why I have a different username - however, I had the same issue on this one.

I realize that you are passing it as an include directive, however the configure script explicitly seems to want it as an environment variable. Perhaps it worked for you because you had it installed system wide?

twelve17 commented 8 years ago

@JeanAzzopardi , you were absolutely correct! I had leptonica installed via homebrew on my system. I've pushed a code change to include LIBLEPT_HEADERSDIR. Give it a shot and see if it works for you. Thanks!

JeanAzzopardi commented 8 years ago

@twelve17 This worked perfectly, thanks! Got the sample app running in the simulator as well!

I also created a pull request with some additional gems that were required by the build script.

Also, many thanks for the revamp :)

twelve17 commented 8 years ago

Hi @JeanAzzopardi - thanks for the PR and for testing the fix. Very glad the sample app worked too!

JeanAzzopardi commented 8 years ago

@twelve17 No problem, this is very useful for a pet project of mine :) I wonder if it's possible to get this in a cocoapod or carthage though, any ideas how this could ever be done?

twelve17 commented 8 years ago

@JeanAzzopardi I'm sure it's possible. :) I'm not familiar with building either. I believe opencv 3.x needs to get into cocoapods before it can be done. As far as Carthage is concerned, I am building alpr via xcodebuild so I suppose it should be doable there too.

Another challenge will be how to build a dynamic framework, which I ran into a lot of headaches trying to do. Either the linker couldn't find the secondary alpr libraries, or when it did, it couldn't load them for unexplained reasons (the errors were vague).

forcecodema commented 8 years ago

Hi, I have similar problem i cannot resolve

openalpr-ios michal$ bundle exec ./bin/build_frameworks.rb 
options: {}
Package opencv2 is already installed. Skipping build.
Package leptonica is already installed. Skipping build.
Building tesseract for armv7 from /Users/michal/src/openalpr-ios/work/tesseract-3.03
make: *** No rule to make target `clean'.  Stop.
make: *** No rule to make target `distclean'.  Stop.
/Users/michal/src/openalpr-ios/lib/alpr/utils.rb:44:in `execute': Child returned: pid 85645 exit 1 (RuntimeError)
    from /Users/michal/src/openalpr-ios/lib/alpr/utils.rb:74:in `log_execute'
    from /Users/michal/src/openalpr-ios/lib/alpr/package/automake.rb:141:in `do_autoconf_build'
    from /Users/michal/src/openalpr-ios/lib/alpr/package/automake.rb:58:in `build_arch'
    from /Users/michal/src/openalpr-ios/lib/alpr/package/base.rb:53:in `block in install'
    from /Users/michal/src/openalpr-ios/lib/alpr/package/base.rb:52:in `each'
    from /Users/michal/src/openalpr-ios/lib/alpr/package/base.rb:52:in `install'
    from ./bin/build_frameworks.rb:76:in `<main>'

What I can see in work/tesseract-3.03/config.log file is:

ld: in /Users/michal/src/openalpr-ios/output/leptonica.framework//liblept.a(pix1.o), building for OSX, but linking in object file built for iOS, for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)

This is work/build.log:

Executing: SDKROOT='/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS9.2.sdk' CXX='/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/c++' CC='/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/cc' LD='/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ld' AS='/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/as' AR='/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ar' NM='/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/nm' RANLIB='/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ranlib' LDFLAGS='-L/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS9.2.sdk/usr/lib/ -L/Users/michal/src/openalpr-ios/work/leptonica-thin-lib/iPhoneOS-armv7' CFLAGS='-arch armv7 -pipe -no-cpp-precomp -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS9.2.sdk -miphoneos-version-min=9.0 -I/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS9.2.sdk/usr/include/ -I/Users/michal/src/openalpr-ios/output/leptonica.framework/Headers' CPPFLAGS='-arch armv7 -pipe -no-cpp-precomp -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS9.2.sdk -miphoneos-version-min=9.0 -I/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS9.2.sdk/usr/include/ -I/Users/michal/src/openalpr-ios/output/leptonica.framework/Headers' CXXFLAGS='-arch armv7 -pipe -no-cpp-precomp -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS9.2.sdk -miphoneos-version-min=9.0 -I/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS9.2.sdk/usr/include/ -I/Users/michal/src/openalpr-ios/output/leptonica.framework/Headers' PATH='/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin:/Users/michal/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/bin:/Users/michal/.rbenv/versions/2.1.2/bin:/usr/local/Cellar/rbenv/0.4.0/libexec:/Users/michal/.rbenv/shims:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/CrossPack-AVR/bin' BUILD_HOST_NAME='arm-apple-darwin7' LIBLEPT_HEADERSDIR='/Users/michal/src/openalpr-ios/output/leptonica.framework/Headers' bash autogen.sh 2>&1
=======================================================================
Running aclocal

  Something went wrong, bailing out!
twelve17 commented 8 years ago

@forecodema - do you have a system leptonica lib installed elsewhere?

forcecodema commented 8 years ago

I think there is no other leptonica on my system:

michal$ brew unlink leptonica
Error: No such keg: /usr/local/Cellar/leptonica

michal$ brew unlink tesseract
Error: No such keg: /usr/local/Cellar/tesseract
forcecodema commented 8 years ago

Strange - reinstalling autoconf and automake as follows did the trick.

$brew remove autoconf
$brew remove automake
$brew cleanup && brew prune
$brew install automake
twelve17 commented 8 years ago

I got nothin'. :)