1.Building opencv4:
cmake .. -DCMAKE_INSTALL_PREFIX=/home/wwd/software/opencv_4.1.0_build/ -DOPENCV_EXTRA_MODULES_PATH=/home/wwd/software/opencv_contrib-4.1.0/modules/ -DBUILD_SHARED_LIBS=OFF -DBUILD_opencv_world=ON
make -j 20
make install
2.After Building:
I copy all .a files in /home/wwd/software/opencv_4.1.0_build/lib64/opencv4/3rdparty to /home/wwd/software/opencv_4.1.0_build/lib64/ for convenience
3.Compiling my own app.cpp
g++ -static -o app app.cpp -I/home/wwd/software/boost_1.70.0_build/include -I/home/wwd/software/opencv_4.1.0_build/include/opencv4/ -L/home/wwd/software/boost_1.70.0_build/lib -L/home/wwd/software/opencv_4.1.0_build/lib64/ -lpthread -lboost_system -lboost_filesystem -lboost_program_options -lpthread -lboost_system -lboost_filesystem -lboost_program_options -lopencv_img_hash -littnotify -lopencv_world -llibwebp -lpng16 -llibjpeg-turbo -llibtiff -llibprotobuf -llibjasper -lade -lIlmImf -lquirc -lz -lippiw -lippicv
4.Generate many ld errors:
Some of this errors:
to __itt_domain_create_ptr__3_0'
/home/wwd/software/binutils_2.32_build/bin/ld: trace.cpp:(.text._ZN2cv5utils5trace7details8traceArgERKNS2_8TraceArgEd+0xdd): undefined reference to
__itt_metadata_add_ptr__3_0'
/home/wwd/software/binutils_2.32_build/bin/ld: trace.cpp:(.text._ZN2cv5utils5trace7details8traceArgERKNS2_8TraceArgEd+0x1cb): undefined reference to __itt_domain_create_ptr__3_0'
/home/wwd/software/binutils_2.32_build/bin/ld: /home/wwd/software/opencv_4.1.0_build/lib64//libopencv_world.a(trace.cpp.o): in function
cv::utils::trace::details::traceArg(cv::utils::trace::details::TraceArg const&, int)':
trace.cpp:(.text._ZN2cv5utils5trace7details8traceArgERKNS2_8TraceArgEi+0x7a): undefined reference to __itt_api_version_ptr__3_0'
/home/wwd/software/binutils_2.32_build/bin/ld: trace.cpp:(.text._ZN2cv5utils5trace7details8traceArgERKNS2_8TraceArgEi+0x92): undefined reference to
__itt_domain_create_ptr__3_0'
/home/wwd/software/binutils_2.32_build/bin/ld: trace.cpp:(.text._ZN2cv5utils5trace7details8traceArgERKNS2_8TraceArgEi+0xdb): undefined reference to __itt_metadata_add_ptr__3_0'
/home/wwd/software/binutils_2.32_build/bin/ld: trace.cpp:(.text._ZN2cv5utils5trace7details8traceArgERKNS2_8TraceArgEi+0x1c3): undefined reference to
__itt_domain_create_ptr__3_0'
/home/wwd/software/binutils_2.32_build/bin/ld: /home/wwd/software/opencv_4.1.0_build/lib64//libopencv_world.a(trace.cpp.o): in function cv::utils::trace::details::traceArg(cv::utils::trace::details::TraceArg const&, long)':
trace.cpp:(.text._ZN2cv5utils5trace7details8traceArgERKNS2_8TraceArgEl+0x7b): undefined reference to
__itt_api_version_ptr__3_0'
/home/wwd/software/binutils_2.32_build/bin/ld: trace.cpp:(.text._ZN2cv5utils5trace7details8traceArgERKNS2_8TraceArgEl+0x93): undefined reference to __itt_domain_create_ptr__3_0'
/home/wwd/software/binutils_2.32_build/bin/ld: trace.cpp:(.text._ZN2cv5utils5trace7details8traceArgERKNS2_8TraceArgEl+0xdc): undefined reference to
__itt_metadata_add_ptr__3_0'
/home/wwd/software/binutils_2.32_build/bin/ld: trace.cpp:(.text._ZN2cv5utils5trace7details8traceArgERKNS2_8TraceArgEl+0x1cb): undefined reference to __itt_domain_create_ptr__3_0'
/home/wwd/software/binutils_2.32_build/bin/ld: /home/wwd/software/opencv_4.1.0_build/lib64//libopencv_world.a(trace.cpp.o): in function
cv::utils::trace::details::traceArg(cv::utils::trace::details::TraceArg const&, char const*)':
trace.cpp:(.text._ZN2cv5utils5trace7details8traceArgERKNS2_8TraceArgEPKc+0x7f): undefined reference to __itt_api_version_ptr__3_0'
/home/wwd/software/binutils_2.32_build/bin/ld: trace.cpp:(.text._ZN2cv5utils5trace7details8traceArgERKNS2_8TraceArgEPKc+0x97): undefined reference to
__itt_domain_create_ptr__3_0'
/home/wwd/software/binutils_2.32_build/bin/ld: trace.cpp:(.text._ZN2cv5utils5trace7details8traceArgERKNS2_8TraceArgEPKc+0xfc): undefined reference to __itt_metadata_str_add_ptr__3_0'
/home/wwd/software/binutils_2.32_build/bin/ld: trace.cpp:(.text._ZN2cv5utils5trace7details8traceArgERKNS2_8TraceArgEPKc+0x1eb): undefined reference to
__itt_domain_create_ptr__3_0'
collect2: error: ld returned 1 exit status
5.I think these wrong order for linking static opencv libs lead to ld errors, so