-
Notifications
You must be signed in to change notification settings - Fork 9.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Unable to build for arm64 iOS library #4093
Comments
Output for g++ --version: Apple clang version 14.0.3 (clang-1403.0.22.14.1) |
Did you try to add CC and CXX as suggested here: |
@amitdo configure output: maria@Marias-MacBook-Pro arm-apple-darwin64 % ../maria_ios.sh Configuration is done. $ make Documentation will not be built because asciidoc or xsltproc is missing. You cannot build training tools because of missing dependency. make output and the error: sudo make -sj8 |
|
@amitdo What value should be used for arm64 ios library? |
First, you should try to understand the meaning of the build, host, target arguments: As you can see, unless the program you are trying to build is a cross compiler, you should not use
Since both your build (m2) and host (iPhone) are arm 64-bit systems, I don't think you really need to specify them. Unless otherwise proven. it seems that your build issue is not an issue in Tesseract itself. You need to find a good guide that explains how to build a program for iOS with Autotools. |
@amitdo
|
I guess the issue is with other arguments in the configure command (wrong/missing args) or incomplete installation of the apple dev tools. |
I got it working, this is the working script in case it helps anyone:
|
@amitdo i am facing this issue too trying to build for iOS using configure.
i always endup with Do you see something wrong with my parameters? |
@farfromrefug, please review your parameters. It looks like a lot of quotation marks are missing. Tesseract only uses C++ code, so CC or CFLAGS should be removed. And configure normally sets |
@stweil thanks a lot for taking the time to answer. I found a script which set the correct flags for iOS build. By the configure.ac does not handle ios build and tries to add -lrt for iOS which does not exist it seem. We have to patch the Makefile to make it work. |
@farfromrefug Do you have a link to the script that sets the correct flags for iOS build? I also have the issue of NEON symbols being undefined. |
@wolf81 this is what i use to build tesseract https://github.com/Akylas/TesseractBuild |
Current Behavior
Hi,
I'm trying to build a library to reference in iOS arm64 framework, I am building tesseract (latest project version) from source on Mac Ventura M2 machine.
The error is:
By the way, not specifying --host=arm-apple-darwin64 or specifying it as target instead makes the build successful, but when using the library in Xcode iOS framework project, I'm getting
This is the configuration I'm using :
export DEVROOT=/Applications/Xcode.app/Contents/Developer
export SDKROOT="$DEVROOT/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS.sdk"
export CFLAGS="--arch arm64 -pipe -no-cpp-precomp -isysroot $SDKROOT -miphoneos-version-min=10.0 -O2 -fembed-bitcode"
export CPPFLAGS=$CFLAGS
export CXXFLAGS=$CFLAGS
sudo ../configure --host=arm-apple-darwin64 --enable-static=yes --enable-shared=no --disable-graphics --disable-legacy --without-curl
This is the configure output:
checking for arm-apple-darwin64-g++... no
checking for arm-apple-darwin64-clang++... no
checking for g++... g++
checking whether the C++ compiler works... yes
checking for C++ compiler default output file name... a.out
checking for suffix of executables...
checking whether we are cross compiling... no
checking for suffix of object files... o
checking whether the compiler supports GNU C++... yes
checking whether g++ accepts -g... yes
checking for g++ option to enable C++11 features... none needed
checking for a BSD-compatible install... /usr/bin/install -c
checking whether build environment is sane... yes
checking for a race-free mkdir -p... ../config/install-sh -c -d
checking for gawk... no
checking for mawk... no
checking for nawk... no
checking for awk... awk
checking whether make sets $(MAKE)... yes
checking whether make supports the include directive... yes (GNU style)
checking whether make supports nested variables... yes
checking dependency style of g++... gcc3
checking for a sed that does not truncate output... /usr/bin/sed
checking Major version... 5
checking Minor version... 3
checking Point version... 1-22-g24da4
checking whether make supports nested variables... (cached) yes
checking build system type... aarch64-apple-darwin22.3.0
checking host system type... arm-apple-darwin64
checking whether C++ compiler accepts -Werror=unused-command-line-argument... yes
checking whether C++ compiler accepts -mfpu=neon... no
checking for feenableexcept... no
checking whether C++ compiler accepts -fopenmp-simd... yes
checking --enable-float32 argument...
checking --enable-graphics argument... no
checking --enable-legacy argument... no
checking for g++ option to support OpenMP... unsupported
checking for stdio.h... yes
checking for stdlib.h... yes
checking for string.h... yes
checking for inttypes.h... yes
checking for stdint.h... yes
checking for strings.h... yes
checking for sys/stat.h... yes
checking for sys/types.h... yes
checking for unistd.h... yes
checking for tiffio.h... no
checking --enable-opencl argument...
checking for tensorflow/core/framework/graph.pb.h... no
checking if -framework Accelerate works... yes
checking if -framework OpenCL works... yes
checking --enable-visibility argument...
checking whether to use tessdata-prefix... yes
checking if compiling with clang... yes
checking whether to enable debugging...
checking how to print strings... printf
checking for arm-apple-darwin64-gcc... no
checking for gcc... gcc
checking whether the compiler supports GNU C... yes
checking whether gcc accepts -g... yes
checking for gcc option to enable C11 features... none needed
checking whether gcc understands -c and -o together... yes
checking dependency style of gcc... gcc3
checking for a sed that does not truncate output... (cached) /usr/bin/sed
checking for grep that handles long lines and -e... /usr/bin/grep
checking for egrep... /usr/bin/grep -E
checking for fgrep... /usr/bin/grep -F
checking for ld used by gcc... /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ld
checking if the linker (/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ld) is GNU ld... no
checking for BSD- or MS-compatible name lister (nm)... no
checking for arm-apple-darwin64-dumpbin... no
checking for arm-apple-darwin64-link... no
checking for dumpbin... no
checking for link... link -dump
checking the name lister (nm) interface... BSD nm
checking whether ln -s works... yes
checking the maximum length of command line arguments... 786432
checking how to convert aarch64-apple-darwin22.3.0 file names to arm-apple-darwin64 format... func_convert_file_noop
checking how to convert aarch64-apple-darwin22.3.0 file names to toolchain format... func_convert_file_noop
checking for /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ld option to reload object files... -r
checking for arm-apple-darwin64-file... no
checking for file... file
checking for arm-apple-darwin64-objdump... no
checking for objdump... objdump
checking how to recognize dependent libraries... pass_all
checking for arm-apple-darwin64-dlltool... no
checking for dlltool... no
checking how to associate runtime and link libraries... printf %s\n
checking for arm-apple-darwin64-ar... no
checking for ar... ar
checking for archiver @file support... no
checking for arm-apple-darwin64-strip... no
checking for strip... strip
checking for arm-apple-darwin64-ranlib... no
checking for ranlib... ranlib
checking command to parse nm output from gcc object... ok
checking for sysroot... no
checking for a working dd... /bin/dd
checking how to truncate binary pipes... /bin/dd bs=4096 count=1
checking for arm-apple-darwin64-mt... no
checking for mt... no
checking if : is a manifest tool... no
checking for arm-apple-darwin64-dsymutil... no
checking for dsymutil... dsymutil
checking for arm-apple-darwin64-nmedit... no
checking for nmedit... nmedit
checking for arm-apple-darwin64-lipo... no
checking for lipo... lipo
checking for arm-apple-darwin64-otool... no
checking for otool... otool
checking for arm-apple-darwin64-otool64... no
checking for otool64... no
checking for -single_module linker flag... yes
checking for -exported_symbols_list linker flag... yes
checking for -force_load linker flag... yes
checking for dlfcn.h... yes
checking for objdir... .libs
checking if gcc supports -fno-rtti -fno-exceptions... yes
checking for gcc option to produce PIC... -fno-common -DPIC
checking if gcc PIC flag -fno-common -DPIC works... yes
checking if gcc static flag -static works... no
checking if gcc supports -c -o file.o... yes
checking if gcc supports -c -o file.o... (cached) yes
checking whether the gcc linker (/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ld) supports shared libraries... yes
checking dynamic linker characteristics... darwin64 dyld
checking how to hardcode library paths into programs... immediate
checking whether stripping libraries is possible... yes
checking if libtool supports shared libraries... yes
checking whether to build shared libraries... no
checking whether to build static libraries... yes
checking how to run the C++ preprocessor... g++ -E
checking for ld used by g++... /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ld
checking if the linker (/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ld) is GNU ld... no
checking whether the g++ linker (/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ld) supports shared libraries... yes
checking for g++ option to produce PIC... -fno-common -DPIC
checking if g++ PIC flag -fno-common -DPIC works... yes
checking if g++ static flag -static works... no
checking if g++ supports -c -o file.o... yes
checking if g++ supports -c -o file.o... (cached) yes
checking whether the g++ linker (/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ld) supports shared libraries... yes
checking dynamic linker characteristics... darwin64 dyld
checking how to hardcode library paths into programs... immediate
checking whether C++ compiler accepts -std=c++17... yes
checking whether C++ compiler accepts -std=c++20... yes
checking for library containing pthread_create... none required
checking for brew... true
checking for asciidoc... false
checking for xsltproc... true
checking for wchar_t... yes
checking for long long int... yes
checking for arm-apple-darwin64-pkg-config... no
checking for pkg-config... /opt/homebrew/bin/pkg-config
checking pkg-config is at least version 0.9.0... yes
checking for lept >= 1.74... yes
checking for libarchive... no
checking for icu-uc >= 52.1... no
checking for icu-i18n >= 52.1... no
configure: WARNING: icu 52.1 or higher is required, but was not found.
configure: WARNING: Training tools WILL NOT be built.
configure: WARNING: Try to install libicu-dev package.
checking for pango >= 1.38.0... no
configure: WARNING: pango 1.38.0 or higher is required, but was not found.
configure: WARNING: Training tools WILL NOT be built.
configure: WARNING: Try to install libpango1.0-dev package.
checking for cairo... no
configure: WARNING: Training tools WILL NOT be built because of missing cairo library.
configure: WARNING: Try to install libcairo-dev?? package.
checking for pangocairo... no
checking for pangoft2... no
checking that generated files are newer than configure... done
configure: creating ./config.status
config.status: creating include/tesseract/version.h
config.status: creating Makefile
config.status: creating tesseract.pc
config.status: creating tessdata/Makefile
config.status: creating tessdata/configs/Makefile
config.status: creating tessdata/tessconfigs/Makefile
config.status: creating java/Makefile
config.status: creating java/com/Makefile
config.status: creating java/com/google/Makefile
config.status: creating java/com/google/scrollview/Makefile
config.status: creating java/com/google/scrollview/events/Makefile
config.status: creating java/com/google/scrollview/ui/Makefile
config.status: creating include/config_auto.h
config.status: include/config_auto.h is unchanged
config.status: executing depfiles commands
config.status: executing libtool commands
Configuration is done.
You can now build and install tesseract by running:
$ make
$ sudo make install
$ sudo ldconfig
And this is the make output:
Making all in .
CXX src/tesseract-tesseract.o
CXX src/api/libtesseract_la-baseapi.lo
CXX src/api/libtesseract_la-capi.lo
CXX src/api/libtesseract_la-altorenderer.lo
CXX src/api/libtesseract_la-hocrrenderer.lo
CXX src/api/libtesseract_la-lstmboxrenderer.lo
CXX src/api/libtesseract_la-pdfrenderer.lo
CXX src/api/libtesseract_la-renderer.lo
CXX src/api/libtesseract_la-wordstrboxrenderer.lo
CXX src/arch/libtesseract_la-intsimdmatrix.lo
CXX src/ccmain/libtesseract_la-applybox.lo
CXX src/ccmain/libtesseract_la-control.lo
CXX src/ccmain/libtesseract_la-linerec.lo
CXX src/ccmain/libtesseract_la-ltrresultiterator.lo
CXX src/ccmain/libtesseract_la-output.lo
CXX src/ccmain/libtesseract_la-pageiterator.lo
CXX src/ccmain/libtesseract_la-pagesegmain.lo
CXX src/ccmain/libtesseract_la-pagewalk.lo
CXX src/ccmain/libtesseract_la-paragraphs.lo
CXX src/ccmain/libtesseract_la-reject.lo
CXX src/ccmain/libtesseract_la-resultiterator.lo
CXX src/ccmain/libtesseract_la-tessedit.lo
CXX src/ccmain/libtesseract_la-tesseractclass.lo
CXX src/ccmain/libtesseract_la-thresholder.lo
CXX src/ccmain/libtesseract_la-werdit.lo
CXX src/ccstruct/libtesseract_la-blamer.lo
CXX src/ccstruct/libtesseract_la-blobbox.lo
CXX src/ccstruct/libtesseract_la-blobs.lo
CXX src/ccstruct/libtesseract_la-blread.lo
CXX src/ccstruct/libtesseract_la-boxread.lo
CXX src/ccstruct/libtesseract_la-boxword.lo
CXX src/ccstruct/libtesseract_la-ccstruct.lo
CXX src/ccstruct/libtesseract_la-coutln.lo
CXX src/ccstruct/libtesseract_la-detlinefit.lo
CXX src/ccstruct/libtesseract_la-imagedata.lo
CXX src/ccstruct/libtesseract_la-linlsq.lo
CXX src/ccstruct/libtesseract_la-matrix.lo
CXX src/ccstruct/libtesseract_la-mod128.lo
CXX src/ccstruct/libtesseract_la-normalis.lo
CXX src/ccstruct/libtesseract_la-ocrblock.lo
CXX src/ccstruct/libtesseract_la-ocrpara.lo
CXX src/ccstruct/libtesseract_la-ocrrow.lo
CXX src/ccstruct/libtesseract_la-otsuthr.lo
CXX src/ccstruct/libtesseract_la-pageres.lo
CXX src/ccstruct/libtesseract_la-pdblock.lo
CXX src/ccstruct/libtesseract_la-points.lo
CXX src/ccstruct/libtesseract_la-polyaprx.lo
CXX src/ccstruct/libtesseract_la-polyblk.lo
CXX src/ccstruct/libtesseract_la-quadlsq.lo
CXX src/ccstruct/libtesseract_la-quspline.lo
CXX src/ccstruct/libtesseract_la-ratngs.lo
CXX src/ccstruct/libtesseract_la-rect.lo
CXX src/ccstruct/libtesseract_la-seam.lo
CXX src/ccstruct/libtesseract_la-split.lo
CXX src/ccstruct/libtesseract_la-statistc.lo
CXX src/ccstruct/libtesseract_la-stepblob.lo
CXX src/ccstruct/libtesseract_la-werd.lo
CXX src/classify/libtesseract_la-classify.lo
CXX src/dict/libtesseract_la-context.lo
CXX src/dict/libtesseract_la-dawg.lo
CXX src/dict/libtesseract_la-dawg_cache.lo
CXX src/dict/libtesseract_la-dict.lo
CXX src/dict/libtesseract_la-stopper.lo
CXX src/dict/libtesseract_la-trie.lo
CXX src/textord/libtesseract_la-alignedblob.lo
CXX src/textord/libtesseract_la-baselinedetect.lo
CXX src/textord/libtesseract_la-bbgrid.lo
CXX src/textord/libtesseract_la-blkocc.lo
CXX src/textord/libtesseract_la-blobgrid.lo
CXX src/textord/libtesseract_la-ccnontextdetect.lo
CXX src/textord/libtesseract_la-cjkpitch.lo
CXX src/textord/libtesseract_la-colfind.lo
CXX src/textord/libtesseract_la-colpartition.lo
CXX src/textord/libtesseract_la-colpartitionset.lo
CXX src/textord/libtesseract_la-colpartitiongrid.lo
CXX src/textord/libtesseract_la-devanagari_processing.lo
CXX src/textord/libtesseract_la-drawtord.lo
CXX src/textord/libtesseract_la-edgblob.lo
CXX src/textord/libtesseract_la-edgloop.lo
CXX src/textord/libtesseract_la-fpchop.lo
CXX src/textord/libtesseract_la-gap_map.lo
CXX src/textord/libtesseract_la-imagefind.lo
CXX src/textord/libtesseract_la-linefind.lo
CXX src/textord/libtesseract_la-makerow.lo
CXX src/textord/libtesseract_la-oldbasel.lo
CXX src/textord/libtesseract_la-pithsync.lo
CXX src/textord/libtesseract_la-pitsync1.lo
CXX src/textord/libtesseract_la-scanedg.lo
CXX src/textord/libtesseract_la-sortflts.lo
CXX src/textord/libtesseract_la-strokewidth.lo
CXX src/textord/libtesseract_la-tabfind.lo
CXX src/textord/libtesseract_la-tablefind.lo
CXX src/textord/libtesseract_la-tabvector.lo
CXX src/textord/libtesseract_la-tablerecog.lo
CXX src/textord/libtesseract_la-textlineprojection.lo
CXX src/textord/libtesseract_la-textord.lo
CXX src/textord/libtesseract_la-topitch.lo
CXX src/textord/libtesseract_la-tordmain.lo
CXX src/textord/libtesseract_la-tospace.lo
CXX src/textord/libtesseract_la-underlin.lo
CXX src/textord/libtesseract_la-wordseg.lo
CXX src/textord/libtesseract_la-workingpartset.lo
CXX src/wordrec/libtesseract_la-tface.lo
CXX src/wordrec/libtesseract_la-wordrec.lo
CXX src/ccutil/libtesseract_ccutil_la-ccutil.lo
CXX src/ccutil/libtesseract_ccutil_la-clst.lo
CXX src/ccutil/libtesseract_ccutil_la-elst2.lo
CXX src/ccutil/libtesseract_ccutil_la-elst.lo
CXX src/ccutil/libtesseract_ccutil_la-serialis.lo
CXX src/ccutil/libtesseract_ccutil_la-tessdatamanager.lo
CXX src/ccutil/libtesseract_ccutil_la-unicharcompress.lo
CXX src/ccutil/libtesseract_ccutil_la-unicharset.lo
CXX src/ccutil/libtesseract_ccutil_la-params.lo
CXX src/lstm/libtesseract_lstm_la-convolve.lo
CXX src/lstm/libtesseract_lstm_la-fullyconnected.lo
CXX src/lstm/libtesseract_lstm_la-functions.lo
CXX src/lstm/libtesseract_lstm_la-input.lo
CXX src/lstm/libtesseract_lstm_la-lstm.lo
CXX src/lstm/libtesseract_lstm_la-lstmrecognizer.lo
CXX src/lstm/libtesseract_lstm_la-maxpool.lo
CXX src/lstm/libtesseract_lstm_la-network.lo
CXX src/lstm/libtesseract_lstm_la-networkio.lo
CXX src/lstm/libtesseract_lstm_la-parallel.lo
CXX src/lstm/libtesseract_lstm_la-plumbing.lo
CXX src/lstm/libtesseract_lstm_la-recodebeam.lo
CXX src/lstm/libtesseract_lstm_la-reconfig.lo
CXX src/lstm/libtesseract_lstm_la-reversed.lo
CXX src/lstm/libtesseract_lstm_la-series.lo
CXX src/lstm/libtesseract_lstm_la-weightmatrix.lo
CXXLD libtesseract_ccutil.la
CXXLD libtesseract_lstm.la
CXXLD libtesseract.la
CXXLD tesseract
Undefined symbols for architecture arm64:
"tesseract::IntSimdMatrix::intSimdMatrixNEON", referenced from:
tesseract::SIMDDetect::SIMDDetect() in libtesseract.a(libtesseract_la-simddetect.o)
tesseract::SIMDDetect::Update() in libtesseract.a(libtesseract_la-simddetect.o)
"tesseract::DotProductNEON(float const*, float const*, int)", referenced from:
tesseract::SIMDDetect::SIMDDetect() in libtesseract.a(libtesseract_la-simddetect.o)
tesseract::SIMDDetect::Update() in libtesseract.a(libtesseract_la-simddetect.o)
ld: symbol(s) not found for architecture arm64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make[1]: *** [tesseract] Error 1
make: *** [all-recursive] Error 1
Expected Behavior
To produce arm64 library built for iOS
Suggested Fix
No response
tesseract -v
No response
Operating System
macOS 13 Ventura
Other Operating System
No response
uname -a
No response
Compiler
No response
CPU
Apple M2 Pro
Virtualization / Containers
No response
Other Information
No response
The text was updated successfully, but these errors were encountered: