tesseract icon indicating copy to clipboard operation
tesseract copied to clipboard

Undefined symbols for architecture x86_64

Open AC0792 opened this issue 1 year ago • 5 comments

While building the tesseract library using CMake and Xcode , it throws error with undefined symbol for x86_64

Undefined symbols for architecture x86_64: "tesseract::DotProductNEON(float const*, float const*, int)", referenced from: tesseract::SIMDDetect::Update() in lto.o __GLOBAL__sub_I_simddetect.cpp in lto.o "tesseract::IntSimdMatrix::intSimdMatrixNEON", referenced from: tesseract::SIMDDetect::Update() in lto.o __GLOBAL__sub_I_simddetect.cpp in lto.o ld: symbol(s) not found for architecture x86_64 clang: error: linker command failed with exit code 1 (use -v to see invocation)

Building on Mac mini with below command

cmake .. -G Xcode -DCMAKE_OSX_ARCHITECTURES="x86_64;arm64" -DCMAKE_OSX_SYSROOT="iphoneos" -DCMAKE_TOOLCHAIN_FILE=../toolchain.cmake -DCMAKE_INSTALL_PREFIX=../../tesseract_lib_xcode-1 -DENABLE_BITCODE=0 -DPLATFORM=OS64COMBINED -DBUILD_SHARED_LIBS=OFF -DBUILD_TRAINING_TOOLS=OFF -DGRAPHIC_DISABLED=ON -DENABLE_LTO=ON

cmake --build . --config Release --target install

Using latest tesseract code (5.2.0)

AC0792 avatar Sep 13 '22 08:09 AC0792

Our CMake build does not currently support building for two architectures simultaneously.

amitdo avatar Sep 14 '22 07:09 amitdo

I have fixed it by using some workaround in simddetect.cpp file

by changing below condition in SIMDDetect() constructor and update() method in same class. Existing condition #if defined(HAVE_NEON) || defined(aarch64) Changed to #if defined(HAVE_NEON) && defined(aarch64)

it worked for 2 architectures simultaneously.

Thanks for Reply :)

AC0792 avatar Sep 14 '22 08:09 AC0792

The right solution is to modify the CMakeLists.txt file to support this combination.

amitdo avatar Sep 14 '22 08:09 amitdo

Maybe your solution is also right.

amitdo avatar Sep 14 '22 08:09 amitdo

May be ! HAVE_NEON variable in CMakeLists.txt , i think has to handle properly which prohibit compiling/building library for 2 architectures simultaneously. I agree it should be handled in CMakeLists.txt instead changing in cpp file.

AC0792 avatar Sep 14 '22 09:09 AC0792