Ask Your Question
0

OpenCV4: what is the order for linking static libs on centos 6

asked 2019-09-01 04:25:13 -0500

Deng gravatar image

updated 2019-09-01 05:42:01 -0500

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 functioncv::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 functioncv::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 wrong order of linking static opencv libs lead to ld errors, so what is the order for linking static libs? Anybody can help?

edit retag flag offensive close merge delete

Comments

See in https://stackoverflow.com/questions/4..., Someone said "-Wl,--start-group" g++ option may work... I will try it

Deng gravatar imageDeng ( 2019-09-01 07:05:09 -0500 )edit

1 answer

Sort by ยป oldest newest most voted
0

answered 2019-10-13 22:44:25 -0500

Deng gravatar image

Using OpenCV3 and pkg-config is a solution!

edit flag offensive delete link more
Login/Signup to Answer

Question Tools

1 follower

Stats

Asked: 2019-09-01 04:25:13 -0500

Seen: 32 times

Last updated: Oct 13