question
Project requirements: cross-compile opencv and port it to arm.
In the compilation of opencv2.0 and above, you need to use the cmake tool to generate Makefile
Only versions below 2.0 use configure to generate Makefile
Please make sure that the host machine has installed cmake and cmake-gui tools. If so, please install them yourself.
sudo apt-get install cmake cmake-qt-gui cmake-curses-gui
Development Environment
Host machine: Fedora9.0
Cross compiler: friendly arm arm-linux-gcc4.4.3
Automatic compilation tool: cmake version 2.8.12.2
Compile
Download opencv source code
Project official website: http://opencv.org/
Download address: http://opencv.org/downloads.html
I put the source code in my own directory /opencv/opev3.0.0-src
The expected build directory is under /opencv/opencv3-build
The expected installation directory is /opt/arm/opencv/opencv3-arm
cmake configuration to generate makefile
Run cmake's graphical tool cmake-gui
sudo cmake-gui
Select the source code directory /opencv/opev3.0.0-src
Select Build directory/opencv/opencv3-build, and configure the compilation directory according to your own settings.
Click Configure or Generator
Select Unix Makefiles,
Then select Specify options for cross-compiling,
Click Next to start configuring the cross-compilation environment information.
Fill in arm-inux for Operating System
C CompilersFill in the address of your cross compiler arm-linux-gcc command
C++ Compilers fill in the address of arm-linux-g++
The Target Root of the library is filled in with the bin directory of the cross compiler.
Then click Finish and your configuration information will be displayed.
Note that the default installation path is to modify the default configuration, and the default installation directory is /usr/local
But it is not suitable for cross-compilation, as it will replace the original library on our host machine.
So I changed the CMAKE_INSTALL_PREFIX variable to /opt/arm/opencv/opencv3-arm
Okay, finally click Configure to configure, and then click Gennerate to generate the Makefile
Make compile and install
sudo make
sudo make install
problem appear
There must be something wrong with the configuration we just did, because a bunch of dependent libraries have no configuration link parameters, but we don’t know which libraries are needed, so we can only wait for problems to occur and solve them.
pthread
Report an error
Linking CXX executable ../../bin/opencv_test_calib3d
../../lib/libopencv_core.so: undefined reference to `pthread_key_create'
../../lib/libopencv_core.so: undefined reference to `pthread_getspecific'
../../lib/libopencv_ts.so: undefined reference to `pthread_key_delete'
../../lib/libopencv_core.so: undefined reference to `pthread_once'
../../lib/libopencv_core.so: undefined reference to `clock_gettime'
../../lib/libopencv_core.so: undefined reference to `pthread_setspecific'
It is obviously the pthread library.
solve
Modify CMakeCache.txt in the /opt/opencv3-build directory
CMAKE_EXE_LINKER_FLAGS was originally empty, add -lpthread -lrt
dlfcn
question
undefined reference to `dlerror'
undefined reference to `dlopen'
solve
CMAKE_EXE_LINKER_FLAGS continues to add -ldl
parallel_pthreads_set_threads_num
question
undefined reference to `dlerror'
undefined reference to `dlopen'
Linking CXX executable ../../bin/opencv_perf_core
../../lib/libopencv_core.so: undefined reference to `parallel_pthreads_set_threads_num(int)'
../../lib/libopencv_core.so: undefined reference to `parallel_pthreads_get_threads_num()'
../../lib/libopencv_core.so: undefined reference to `parallel_for_pthreads(cv::Range const&, cv::ParallelLoopBody const&, double)'
solve
This is a problem with the compilation tool chain, which was solved in almost a day
Later, I found a solution: Fixed compilation of pthread-based parallel_for with gcc 4.4.3
Modify modules/core/src/parallel.cpp, add 7 places and delete 5 places starting from line 132 (+ indicates to add, - indicates to delete)
namespace cv
{
ParallelLoopBody::~ParallelLoopBody() {}
+#if defined HAVE_PTHREADS && HAVE_PTHREADS
+ void parallel_for_pthreads(const cv::Range& range, const cv::ParallelLoopBody& body, double nstripes);
+ size_t parallel_pthreads_get_threads_num();
+ void parallel_pthreads_set_threads_num(int num);
+#endif
}
+
namespace
{
#ifdef CV_PARALLEL_FRAMEWORK
@@ -301,7 +307,7 @@ void cv::parallel_for_(const cv::Range& range, const cv::ParallelLoopBody& body,
}
#elif defined HAVE_PTHREADS
- void parallel_for_pthreads(const Range& range, const ParallelLoopBody& body, double nstripes);
+
parallel_for_pthreads(range, body, nstripes);
#else
@@ -361,8 +367,6 @@ int cv::getNumThreads(void)
#elif defined HAVE_PTHREADS
- size_t parallel_pthreads_get_threads_num();
-
return parallel_pthreads_get_threads_num();
#else
@@ -424,8 +428,6 @@ void cv::setNumThreads( int threads )
#elif defined HAVE_PTHREADS
- void parallel_pthreads_set_threads_num(int num);
-
parallel_pthreads_set_threads_num(threads);
#endif
Previous article:Building QT/Embedded4.8.5 development environment on s3c2410 (VI) --Configuration of QtCreate
Next article:Summary of common error messages of mount nfs
- Popular Resources
- Popular amplifiers
- Naxin Micro and Xinxian jointly launched the NS800RT series of real-time control MCUs
- How to learn embedded systems based on ARM platform
- Summary of jffs2_scan_eraseblock issues
- Application of SPCOMM Control in Serial Communication of Delphi7.0
- Using TComm component to realize serial communication in Delphi environment
- Bar chart code for embedded development practices
- Embedded Development Learning (10)
- Embedded Development Learning (8)
- Embedded Development Learning (6)
Professor at Beihang University, dedicated to promoting microcontrollers and embedded systems for over 20 years.
- Intel promotes AI with multi-dimensional efforts in technology, application, and ecology
- ChinaJoy Qualcomm Snapdragon Theme Pavilion takes you to experience the new changes in digital entertainment in the 5G era
- Infineon's latest generation IGBT technology platform enables precise control of speed and position
- Two test methods for LED lighting life
- Don't Let Lightning Induced Surges Scare You
- Application of brushless motor controller ML4425/4426
- Easy identification of LED power supply quality
- World's first integrated photovoltaic solar system completed in Israel
- Sliding window mean filter for avr microcontroller AD conversion
- What does call mean in the detailed explanation of ABB robot programming instructions?
- GigaDevice's full range of automotive-grade SPI NOR Flash GD25/55 wins ISO 26262 ASIL D functional safety certification
- GigaDevice's full range of automotive-grade SPI NOR Flash GD25/55 wins ISO 26262 ASIL D functional safety certification
- New IsoVu™ Isolated Current Probes: Bringing a New Dimension to Current Measurements
- New IsoVu™ Isolated Current Probes: Bringing a New Dimension to Current Measurements
- Infineon Technologies Launches ModusToolbox™ Motor Kit to Simplify Motor Control Development
- Infineon Technologies Launches ModusToolbox™ Motor Kit to Simplify Motor Control Development
- STMicroelectronics IO-Link Actuator Board Brings Turnkey Reference Design to Industrial Monitoring and Equipment Manufacturers
- Melexis uses coreless technology to reduce the size of current sensing devices
- Melexis uses coreless technology to reduce the size of current sensing devices
- Vicor high-performance power modules enable the development of low-altitude avionics and EVTOL
- GD32L233C-START Development Board Evaluation 2: GD32L233C Chip Low Power Performance Test 1
- Solution to debugging DAbt_Handler problem
- 【Gravity:AS7341 Review】+ Comparative Analysis between Color Sensors
- The next industrial revolution relies on wireless connectivity
- Playing with Zynq Serial 20: Modular Design Based on FPGA
- A novice asked a question about the if statement in C language
- [SAMR21 New Gameplay] 9. Serial Communication-2
- I just used the 1904 version of AD and why can't I get 3D display in LIB
- 35 "Ten Thousand Miles" Raspberry Pi Car——ROS Learning (Realizing Hello World)
- Ask for a lithium battery boost solution