我正在尝试在Ubuntu 16.04.7 LTS
(在 docker 容器中)编译 OpenALPR 库,所有帖子似乎都表明工具集的进步每隔几年就会导致编译中断 - 如下图所示,我得到永久链接错误。
对于那些以前构建过的人,我的 CMAKE 命令如下:
cmake \
-DANDROID_TOOLCHAIN=clang \
-DCMAKE_TOOLCHAIN_FILE=$NDK_ROOT/build/cmake/android.toolchain.cmake \
-DANDROID_NDK=$NDK_ROOT \
-DCMAKE_BUILD_TYPE=Release \
-DANDROID_PLATFORM=$ANDROID_PLATFORM \
-DANDROID_ABI="$i" \
-DANDROID_STL=c++_static \
-DANDROID_CPP_FEATURES="rtti exceptions" \
-DTesseract_INCLUDE_BASEAPI_DIR=$TESSERACT_SRC_DIR/api \
-DTesseract_INCLUDE_CCSTRUCT_DIR=$TESSERACT_SRC_DIR/ccstruct \
-DTesseract_INCLUDE_CCMAIN_DIR=$TESSERACT_SRC_DIR/ccmain \
-DTesseract_INCLUDE_CCUTIL_DIR=$TESSERACT_SRC_DIR/ccutil \
-DTesseract_LIB=$TESSERACT_LIB_DIR/libtess.so \
-DLeptonica_LIB=$TESSERACT_LIB_DIR/liblept.so \
-DOpenCV_DIR=$OpenCV_DIR \
-DJAVA_AWT_LIBRARY=$JAVA_AWT_LIBRARY \
-DJAVA_JVM_LIBRARY=$JAVA_JVM_LIBRARY \
-DJAVA_INCLUDE_PATH=$JAVA_INCLUDE_PATH \
-DJAVA_INCLUDE_PATH2=$JAVA_INCLUDE_PATH2 \
-DJAVA_AWT_INCLUDE_PATH=$JAVA_AWT_INCLUDE_PATH \
-DPngt_LIB=$TESSERACT_LIB_DIR/libpngt.so \
-DJpgt_LIB=$TESSERACT_LIB_DIR/libjpgt.so \
-DJnigraphics_LIB=$NDK_ROOT/platforms/$ANDROID_PLATFORM/arch-$arch/usr/$lib/libjnigraphics.so \
-DANDROID_ARM_MODE=arm \
../../src/
cmake --build . -- -j 8 -error-limit=0
上面的一些变量先前声明为:
export ANDROID_HOME=/usr/lib/android-sdk
export NDK_ROOT=/usr/lib/android-sdk/ndk-bundle
export OpenCV_DIR=$PWD/OpenCV-android-sdk/OpenCV-android-sdk/sdk
ANDROID_PLATFORM="android-21"
JAVA_HOME=/usr/lib/jvm/jdk1.8.0_281
JAVA_AWT_LIBRARY=$JAVA_HOME/jre/lib/amd64
JAVA_JVM_LIBRARY=$JAVA_HOME/jre/lib/amd64
JAVA_INCLUDE_PATH=$JAVA_HOME/include
JAVA_INCLUDE_PATH2=$JAVA_HOME/include/linux
JAVA_AWT_INCLUDE_PATH=$JAVA_HOME/include
以及在哪里:
$i
只是 do 循环中正在考虑的特定 abi(即 armeabi-v7a、arm64-v8a 等)...
然而,在大约 61% 的构建中,我收到以下错误(仅显示前 5 个,未显示另一个 180-ish):
[ 61%] Linking CXX executable openalpr-utils-prepcharsfortraining
ld: error: undefined symbol: cv::imwrite(cv::String const&, cv::_InputArray const&, std::__ndk1::vector<int, std::__ndk1::allocator<int> > const&)
>>> referenced by prepcharsfortraining.cpp:224 (/root/openalpr/src/misc_utilities/prepcharsfortraining.cpp:224)
>>> CMakeFiles/openalpr-utils-prepcharsfortraining.dir/prepcharsfortraining.cpp.o:(main)
ld: error: undefined symbol: std::ios_base::ios_base()
>>> referenced by loadsave.cpp
>>> loadsave.cpp.o:(cv::ApplyExifOrientation(cv::String const&, cv::Mat&)) in archive /root/OpenCV-android-sdk/OpenCV-android-sdk/sdk/native/staticlibs/armeabi-v7a/libopencv_imgcodecs.a
>>> referenced by persistence_base64.cpp
>>> persistence_base64.cpp.o:(base64::RawDataToBinaryConvertor::make_to_binary_funcs(std::string const&)) in archive /root/OpenCV-android-sdk/OpenCV-android-sdk/sdk/native/staticlibs/armeabi-v7a/libopencv_core.a
>>> referenced by ImfStdIO.cpp
>>> ImfStdIO.cpp.o:(Imf::StdIFStream::StdIFStream(char const*)) in archive /root/OpenCV-android-sdk/OpenCV-android-sdk/sdk/native/3rdparty/libs/armeabi-v7a/libIlmImf.a
>>> referenced 2 more times
ld: error: undefined symbol: std::basic_ios<char, std::char_traits<char> >::init(std::basic_streambuf<char, std::char_traits<char> >*)
>>> referenced by loadsave.cpp
>>> loadsave.cpp.o:(cv::ApplyExifOrientation(cv::String const&, cv::Mat&)) in archive /root/OpenCV-android-sdk/OpenCV-android-sdk/sdk/native/staticlibs/armeabi-v7a/libopencv_imgcodecs.a
>>> referenced by loadsave.cpp
>>> loadsave.cpp.o:(cv::ApplyExifOrientation(cv::String const&, cv::Mat&)) in archive /root/OpenCV-android-sdk/OpenCV-android-sdk/sdk/native/staticlibs/armeabi-v7a/libopencv_imgcodecs.a
>>> referenced by persistence_base64.cpp
>>> persistence_base64.cpp.o:(base64::RawDataToBinaryConvertor::make_to_binary_funcs(std::string const&)) in archive /root/OpenCV-android-sdk/OpenCV-android-sdk/sdk/native/staticlibs/armeabi-v7a/libopencv_core.a
>>> referenced 7 more times
ld: error: undefined symbol: std::basic_filebuf<char, std::char_traits<char> >::basic_filebuf()
>>> referenced by loadsave.cpp
>>> loadsave.cpp.o:(cv::ApplyExifOrientation(cv::String const&, cv::Mat&)) in archive /root/OpenCV-android-sdk/OpenCV-android-sdk/sdk/native/staticlibs/armeabi-v7a/libopencv_imgcodecs.a
>>> referenced by ImfStdIO.cpp
>>> ImfStdIO.cpp.o:(Imf::StdIFStream::StdIFStream(char const*)) in archive /root/OpenCV-android-sdk/OpenCV-android-sdk/sdk/native/3rdparty/libs/armeabi-v7a/libIlmImf.a
>>> referenced by ImfStdIO.cpp
>>> ImfStdIO.cpp.o:(Imf::StdOFStream::StdOFStream(char const*)) in archive /root/OpenCV-android-sdk/OpenCV-android-sdk/sdk/native/3rdparty/libs/armeabi-v7a/libIlmImf.a
ld: error: undefined symbol: std::basic_filebuf<char, std::char_traits<char> >::open(char const*, std::_Ios_Openmode)
>>> referenced by loadsave.cpp
>>> loadsave.cpp.o:(cv::ApplyExifOrientation(cv::String const&, cv::Mat&)) in archive /root/OpenCV-android-sdk/OpenCV-android-sdk/sdk/native/staticlibs/armeabi-v7a/libopencv_imgcodecs.a
>>> referenced by ImfStdIO.cpp
>>> ImfStdIO.cpp.o:(Imf::StdIFStream::StdIFStream(char const*)) in archive /root/OpenCV-android-sdk/OpenCV-android-sdk/sdk/native/3rdparty/libs/armeabi-v7a/libIlmImf.a
>>> referenced by ImfStdIO.cpp
>>> ImfStdIO.cpp.o:(Imf::StdOFStream::StdOFStream(char const*)) in archive /root/OpenCV-android-sdk/OpenCV-android-sdk/sdk/native/3rdparty/libs/armeabi-v7a/libIlmImf.a
在继续下一个 abi 并重复相同的错误之前的最终错误消息如下:
ld: error: too many errors emitted, stopping now (use -error-limit=0 to see all errors)
clang++: error: linker command failed with exit code 1 (use -v to see invocation)
openalpr/CMakeFiles/openalpr.dir/build.make:778: recipe for target 'openalpr/libopenalpr.so' failed
make[2]: *** [openalpr/libopenalpr.so] Error 1
CMakeFiles/Makefile2:579: recipe for target 'openalpr/CMakeFiles/openalpr.dir/all' failed
make[1]: *** [openalpr/CMakeFiles/openalpr.dir/all] Error 2
Makefile:155: recipe for target 'all' failed
当最后一批破损似乎出现时,我已经做了几年前推荐的常见事情,相对于:
更改 cmake 属性:
-DANDROID_STL=gnustl_static \
至
-DANDROID_STL=c++_shared \
此外,在此之前,我成功地在同一个脚本(tesseract 等)中构建了所有 3rd 方库,因此所有对象都构建在这个平台上。
有任何想法吗?
亲切的问候!