Skip to content
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

Closed
tigrenok00 opened this issue Jun 22, 2023 · 15 comments
Closed

Unable to build for arm64 iOS library #4093

tigrenok00 opened this issue Jun 22, 2023 · 15 comments

Comments

@tigrenok00
Copy link

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:

Undefined symbols for architecture arm64:
  "tesseract::IntSimdMatrix::intSimdMatrixNEON"

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

ld: in /Users/XX/XX/XX/libtesseract.a(libtesseract_la-baseapi.o), building for iOS, but linking in object file built for macOS, file '/Users/XX/XX/XX/libtesseract.a' for architecture arm64
clang: error: linker command failed with exit code 1 (use -v to see invocation)

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

@amitdo
Copy link
Collaborator

amitdo commented Jun 23, 2023

#2334

@tigrenok00
Copy link
Author

Output for g++ --version:

Apple clang version 14.0.3 (clang-1403.0.22.14.1)
Target: arm64-apple-darwin22.3.0
Thread model: posix
InstalledDir: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin

@amitdo
Copy link
Collaborator

amitdo commented Jun 25, 2023

Did you try to add CC and CXX as suggested here:
#2334 (comment)
?

@tigrenok00
Copy link
Author

@amitdo
Hi, yes:
sudo ../configure CXX=clang++ CC=clang CFLAGS="--disable-asm-optimizations" --host=arm-apple-darwin64 --target=arm-apple-darwin64 --enable-static=yes --enable-shared=no --disable-graphics --disable-legacy --without-curl

configure output:

maria@Marias-MacBook-Pro arm-apple-darwin64 % ../maria_ios.sh
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 clang++ accepts -g... yes
checking for clang++ 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 clang++... 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 clang++ 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... clang
checking whether the compiler supports GNU C... no
checking whether clang accepts -g... yes
checking for clang option to enable C11 features... unsupported
checking for clang option to enable C99 features... unsupported
checking for clang option to enable C89 features... unsupported
checking whether clang understands -c and -o together... yes
checking dependency style of clang... 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 non-GNU ld... /usr/bin/ld
checking if the linker (/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 /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 clang 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... no
checking for -exported_symbols_list linker flag... yes
checking for -force_load linker flag... no
checking for dlfcn.h... yes
checking for objdir... .libs
checking for clang option to produce PIC... -fno-common -DPIC
checking if clang PIC flag -fno-common -DPIC works... no
checking if clang static flag works... no
checking if clang supports -c -o file.o... no
checking if clang supports -c -o file.o... (cached) no
checking if we can lock with hard links... yes
checking whether the clang linker (/usr/bin/ld) supports shared libraries... no
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... no
checking whether to build shared libraries... no
checking whether to build static libraries... yes
checking how to run the C++ preprocessor... clang++ -E
checking for ld used by clang++... /usr/bin/ld
checking if the linker (/usr/bin/ld) is GNU ld... no
checking whether the clang++ linker (/usr/bin/ld) supports shared libraries... yes
checking for clang++ option to produce PIC... -fno-common -DPIC
checking if clang++ PIC flag -fno-common -DPIC works... yes
checking if clang++ static flag -static works... no
checking if clang++ supports -c -o file.o... yes
checking if clang++ supports -c -o file.o... (cached) yes
checking whether the clang++ linker (/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: 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

Documentation will not be built because asciidoc or xsltproc is missing.

You cannot build training tools because of missing dependency.
Check configure output for details.

make output and the error:

sudo make -sj8
Making all in .
CXX src/arch/libtesseract_native_la-dotproduct.lo
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/arch/libtesseract_la-simddetect.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-mutableiterator.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-tessvars.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-dppoint.lo
CXX src/ccstruct/libtesseract_la-image.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-rejctmap.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-textlineprojection.lo
CXX src/textord/libtesseract_la-tablerecog.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-tovars.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-errcode.lo
CXX src/ccutil/libtesseract_ccutil_la-serialis.lo
CXX src/ccutil/libtesseract_ccutil_la-scanutils.lo
CXX src/ccutil/libtesseract_ccutil_la-tessdatamanager.lo
CXX src/ccutil/libtesseract_ccutil_la-unichar.lo
CXX src/ccutil/libtesseract_ccutil_la-tprintf.lo
CXX src/ccutil/libtesseract_ccutil_la-unicharmap.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-stridemap.lo
CXX src/lstm/libtesseract_lstm_la-tfnetwork.lo
CXX src/lstm/libtesseract_lstm_la-weightmatrix.lo
CXXLD libtesseract_native.la
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)**

@amitdo
Copy link
Collaborator

amitdo commented Jun 25, 2023

arm-apple-darwin64 is not a valid value for build/host/target.

@tigrenok00
Copy link
Author

@amitdo What value should be used for arm64 ios library?

@amitdo
Copy link
Collaborator

amitdo commented Jun 25, 2023

First, you should try to understand the meaning of the build, host, target arguments:
https://www.gnu.org/software/automake/manual/html_node/Cross_002dCompilation.html

As you can see, unless the program you are trying to build is a cross compiler, you should not use --target.

arm64-apple-darwin and aarch64-apple-darwin seems to be valid values.

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.

@tigrenok00
Copy link
Author

@amitdo
If I omit target and try host = arm64-apple-darwin or aarch64-apple-darwin (or omit host as well) then configure and make are okay, but when I try to link the library in Xcode in my project I get:

ld: in /Users/maria/git_projects/XXX/libtesseract.a(libtesseract_la-baseapi.o), building for iOS, but linking in object file built for macOS, file '/Users/maria/git_projects/XXX/libtesseract.a' for architecture arm64

@amitdo
Copy link
Collaborator

amitdo commented Jun 26, 2023

I guess the issue is with other arguments in the configure command (wrong/missing args) or incomplete installation of the apple dev tools.

@tigrenok00
Copy link
Author

I got it working, this is the working script in case it helps anyone:


OPT_FLAGS="-O3 -g3"
MAKE_JOBS=16

dobuild() {
    make distclean

    export CC
    CC=$(xcrun --find --sdk "${SDK}" gcc)
    export CXX
    CXX=$(xcrun --find --sdk "${SDK}" g++)
    export CFLAGS
    CFLAGS="${HOST_FLAGS} ${OPT_FLAGS}"
    export CXXFLAGS
    CXXFLAGS="${HOST_FLAGS} ${OPT_FLAGS}"
    export LDFLAGS
    LDFLAGS="${HOST_FLAGS}"
    export LIBLEPT_LIBDIR="${HOME}/git_projects/leptonica/output/device_arm/lib"
    export LIBLEPT_HEADERSDIR="${HOME}/git_projects/leptonica/output/device_arm/include/leptonica"
    export PKG_CONFIG_PATH="${HOME}/git_projects/leptonica/output"

    ../configure --host="${CHOST}"  --prefix="${PREFIX}" --enable-static --without-curl --disable-graphics --disable-legacy 
    make -j"${MAKE_JOBS}"
    make install
}

SDK="iphoneos"
ARCH_FLAGS="-arch arm64"
HOST_FLAGS="${ARCH_FLAGS} -miphoneos-version-min=10.0 -isysroot $(xcrun --sdk ${SDK} --show-sdk-path)"
CHOST="aarch64-apple-darwin"
PREFIX="${HOME}/git_projects/tesseract/arm-apple-darwin64/DEVICE_ARM"
dobuild

@amitdo amitdo closed this as completed Jun 28, 2023
@farfromrefug
Copy link

farfromrefug commented Nov 21, 2023

@amitdo i am facing this issue too trying to build for iOS using configure.
My issue is that whatever parameters i pass to configure :

configure CC=/Applications/Xcode-14.3.0.app/Contents/Developer/usr/bin/gcc CXX=/Applications/Xcode-14.3.0.app/Contents/Developer/usr/bin/g++ CXX_FOR_BUILD=/Applications/Xcode-14.3.0.app/Contents/Developer/usr/bin/g++ CFLAGS=-std=c++17 -stdlib=libc++ -arch arm64 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS.sdk -I/Volumes/dev/ios/tesseract-build/Root/ios_arm64/ -miphoneos-version-min=14.3 --target=arm64-apple-ios14.3 -fembed-bitcode -O3 -g3 -pipe CPPFLAGS=-std=c++17 -stdlib=libc++ -arch arm64 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS.sdk -I/Volumes/dev/ios/tesseract-build/Root/ios_arm64/ -miphoneos-version-min=14.3 --target=arm64-apple-ios14.3 -fembed-bitcode -O3 -g3 -pipe CXXFLAGS=-std=c++17 -stdlib=libc++ -arch arm64 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS.sdk -I/Volumes/dev/ios/tesseract-build/Root/ios_arm64/ -miphoneos-version-min=14.3 --target=arm64-apple-ios14.3 -O3 -g3 -pipe LDFLAGS=-L/Volumes/dev/ios/tesseract-build/Root/ios_arm64/lib -L/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS.sdk/usr/lib/ LIBLEPT_HEADERSDIR=/Volumes/dev/ios/tesseract-build/Root/ios_arm64/include LIBS=-lz -lpng PKG_CONFIG_PATH=/Volumes/dev/ios/tesseract-build/Root/ios_arm64/lib/pkgconfig --enable-openmp=yes --enable-static=yes --enable-shared=no --disable-graphics --disable-legacy --without-curl --host=arm64-apple-ios14.3 --prefix=/Volumes/dev/ios/tesseract-build/Root/ios_arm64

i always endup with __aarch64__ defined but HAVE_NEON not defined.
I see that configure fails to build with -mfpu=neon thus not setting HAVE_NEON while __aarch64__. This ends up in a configuration not working in simdetect because intsimdmatrix is only "defined" when HAVE_NEON is true and not when __aarch64__ is true. Almost feels like something is wrong in intsimdmatrix and it should also be defined when __aarch64__ is defined

Do you see something wrong with my parameters?

@stweil
Copy link
Contributor

stweil commented Nov 21, 2023

@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 HAVE_NEON for aarch64 builds. If it does not in your build, I suggest to debug the configure script to see why it fails to do so.

@farfromrefug
Copy link

@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.
But i got it to build. Yet have to test it.
thanks

@wolf81
Copy link

wolf81 commented Apr 12, 2024

@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.

@farfromrefug
Copy link

@wolf81 this is what i use to build tesseract https://github.com/Akylas/TesseractBuild

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants