I have been installing 4.5.4 on two Odroid boards, running Linux, to compare install steps, one being an XU4 (32 bit) armhf and the other a N2+ (64 bit) aarch64. Managed to complete an install on XU4 but had some problems with N2+, aarch64 needing extra options on cmake, the first two to stop build errors with videoio and the third with a further compilation error in the Python module build.
-D BUILD_opencv_videoio=OFF
-D WITH_FFMPEG=ON
-D BUILD_opencv_python3=OFF
I have been using previous versions of OpenCV on the XU4 board for the last 4-5 years and always had some problems to get round, but the aarch64 is a bit more challenging. The installation completed successfully but I think that there is a lack information on installation in aarch64. Has anyone else tried this path?
Installation of OpenCV 4.x on aarch64 for native compile was failing install while, I assume, trying to link videoio.
Berak’s comment to this original post suggested I look at the build bot for info. As far as I could see the build bot failed on every attempt to build for aarch64!
The output after previous make attempts suggested that Position Independent Code needs to be used and suggested recompile with -fPIC flag set. I searched for clues on this in the Opencv docs and tried cmake with -D ENABLE_PIC=ON. Same result ensued.
I then started wondering if it was something to do with FFmpeg as OpenCV 4.x install docs suggested use of ffmpeg v5.x. I started searching for “FFmpeg”, “-fPIC” and “aarch64” and came across various issues. That started me thinking that it wasn’t the OpenCV install processs that was generating the error but somehow FFmpeg was issuing warnings possibly from the linkage process. So after a fair bit of browsing of ffmpeg-trac issues, I got a good clue from #9612 (--enable-pic flag doesn't affect the object files from assembly) – FFmpeg .
I worked out how I thought I need to proceed to re-compile ffmpeg with aarch64 Position Independent Code.
I recompiled ffmpeg using the following:-
/configure --enable-shared --extra-cflags=“-fPIC” --enable-pic
make
sudo make install
The ffmpeg compilation took a while but after that finished, I tried a fresh install of OpenCV (without opencv_contrib, just to save time!). I set the following cmake flags:-
At last, compilation completed successfully this time. I have been able to compile and run my opencv modules that I have migrated from the 32 bit armv7 XU4, to the aarch64 N2+ platform.
I think this leaves an open question, possibly against ffmpeg!
On Linux, if a later version of ffmpeg is required, apt install only gives earlier versions, v4.x? So ffmpeg has to be downloaded and compiled for that platform.
Should’nt ffmpeg recognize that if it is being compiled on aarch64 that the flags for PIC need to be implemented??
Someone out there may be more familiar with this.
Good to see that you got it passed. These days I also have been struggling to compile opencv-4.7.0 with gstreamer support.
I tried cross-compiling it with lots tries but failed because cmake cannot find my cross-compiled gstreamer.
Now, I am trying native compilation of it on the aarch64 board, and it almost gets to the target.