Help compiling to Linux arm64
Hello,
@tomoaki0705 said this is a good place to ask for help on opencv on this topic.
As you can see in the link, I'm having trouble compiling OpenCV to Linux (Debian) arm64. This is what I'm using right now, copied from the github issue, slightly edited to not disable neon:
Cross compile using an extended dockcross script. Let's call it linux-arm64
and save it in a folder called dockerfiles
FROM dockcross/linux-arm64
ENV DEFAULT_DOCKCROSS_IMAGE linux-arm64
# Set up CCache
RUN apt-get -y install ccache
ENV CCACHE_DIR=/.ccache
RUN mkdir /.ccache
RUN chmod 777 /.ccache
# Install required libraries
RUN apt-get -y install libavcodec-dev:arm64 libavformat-dev:arm64 libswscale-dev:arm64 libjpeg-dev:arm64 libpng-dev:arm64 libtiff-dev:arm64 libdc1394-22:arm64 libdc1394-22-dev:arm64
RUN apt-get -y install --no-install-recommends libgtk2.0-dev:arm64
# cd to /opencv and download OpenCV source
WORKDIR /opencv
RUN wget https://github.com/opencv/opencv/archive/3.4.0.zip
RUN apt-get install unzip
RUN unzip 3.4.0.zip
RUN ln -s /opencv/opencv-3.4.0 /opencv/opencv
# Create build folder
WORKDIR /opencv/opencv
RUN mkdir /opencv/opencv/build
WORKDIR /opencv/opencv/build
ENV PKG_CONFIG_PATH /usr/lib/aarch64-linux-gnu/pkgconfig/
# Build OpenCV
# ##### The command I really want to use, commented out in favor of a simplified example. RUN cmake -DBUILD_SHARED_LIBS=OFF -DCMAKE_MAKE_PROGRAM=make -DCMAKE_BUILD_TYPE=RELEASE -DCMAKE_INSTALL_PREFIX=/usr/local -DWITH_QT=OFF -DBUILD_EXAMPLES=OFF -DBUILD_PERF_TESTS=OFF -DBUILD_TESTS=OFF -DBUILD_DOCS=OFF -DBUILD_opencv_cudabgsegm=OFF -DBUILD_opencv_superres=OFF -DBUILD_opencv_cudalegacy=OFF -DBUILD_opencv_cudafilters=OFF -DBUILD_opencv_cudastereo=OFF -DBUILD_opencv_cudafeatures2d=OFF -DBUILD_opencv_shape=OFF -DBUILD_opencv_ml=OFF -DBUILD_opencv_stitching=OFF -DBUILD_opencv_python_bindings_generator=OFF -DBUILD_opencv_photo=OFF -DBUILD_opencv_cudaoptflow=OFF -DBUILD_opencv_ts=OFF -DBUILD_opencv_calib3d=OFF -DBUILD_opencv_videostab=OFF -DBUILD_opencv_cudacodec=OFF -DBUILD_opencv_core=ON -DBUILD_opencv_cudaimgproc=OFF -DBUILD_opencv_dnn=OFF -DBUILD_opencv_objdetect=OFF -DBUILD_opencv_apps=OFF -DBUILD_opencv_cudev=OFF -DBUILD_opencv_video=OFF -DBUILD_opencv_cudawarping=OFF -DBUILD_opencv_cudaarithm=OFF -DBUILD_opencv_features2d=OFF -DBUILD_opencv_cudaobjdetect=OFF -DBUILD_opencv_flann=OFF -DCMAKE_TOOLCHAIN_FILE=$CMAKE_TOOLCHAIN_FILE ..
RUN cmake -DCMAKE_TOOLCHAIN_FILE=$CMAKE_TOOLCHAIN_FILE ..
RUN make -j7
RUN make install
WORKDIR /work
Run the following in terminal:
docker build -f dockerfiles/linux-arm64 -t linux-arm64 .
I'm also trying to use clang as an alternative, to no avail yet. Constructing a CMake toolchain for clang is proving very difficult.
Additional question,
Is really "/usr/bin/aarch64-linux-gnu-c++" linked to "/usr/bin/aarch64-linux-gnu-g++" ?
What happens if you do "ls -l /usr/bin/aarch64-linux-gnu-c++" ?
These line really looks like your cmake didn't find g++ correctly. Are you really sure that you're using the correct compiler for cross compilation ?