tesseract
tesseract copied to clipboard
Undefined symbols for architecture x86_64
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)
Our CMake build does not currently support building for two architectures simultaneously.
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 :)
The right solution is to modify the CMakeLists.txt file to support this combination.
Maybe your solution is also right.
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.