Ask Your Question
0

cannnot statically compile opencv code

asked 2016-05-29 07:06:43 -0600

Doha gravatar image

Hello, I have statically cross compiled opencv-2.4.13 for ARM , the installation directory is /Desktop/opencv-build. now I am trying to compile a simple opencv code that displays an image using this command:

/arm-buildroot-linux-uclibcgnueabi-g++ opencv.cpp -L/Desktop/opencv-build/lib/libopencv_highgui.a -L/Desktop/opencv-build/lib/libopencv_imgproc.a -L/Desktop/opencv-build/lib/libopencv_core.a -o ocvccode

I then get this error message

opencv.cpp:(.text+0x7c): undefined reference to cv::imread(std::string const&, int)' opencv.cpp:(.text+0xc8): undefined reference tocv::namedWindow(std::string const&, int)' opencv.cpp:(.text+0x118): undefined reference to cv::_InputArray::_InputArray(cv::Mat const&)' opencv.cpp:(.text+0x12c): undefined reference tocv::imshow(std::string const&, cv::_InputArray const&)' opencv.cpp:(.text+0x14c): undefined reference to cv::waitKey(int)' /tmp/ccksKPb6.o: In functioncv::Mat::~Mat()': opencv.cpp:(.text._ZN2cv3MatD2Ev[_ZN2cv3MatD5Ev]+0x3c): undefined reference to cv::fastFree(void*)' /tmp/ccksKPb6.o: In functioncv::Mat::release()': opencv.cpp:(.text._ZN2cv3Mat7releaseEv[_ZN2cv3Mat7releaseEv]+0x58): undefined reference to `cv::Mat::deallocate()' collect2: error: ld returned 1 exit status

how to solve this and is there is any other way to statically compile opencv code for ARM?

edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted
2

answered 2016-05-29 07:31:40 -0600

berak gravatar image

imread and friends are in the imgcodecs module, so you additionally have to link that lib, also you need the core library:

g++ opencv.cpp -L/Desktop/opencv-build  -lopencv_imgcodecs -lopencv_highgui -lopencv_imgproc -lopencv_core -o ocvccode

then i guess, that you need some dependancy libs (at the end of the list), like:

-llibpng -llibjpeg -llibtiff -llibwebp -llibjasper -lz

don't forget, that with static linking, the order matters, e.g anything depending on zlib must go before zlib

edit flag offensive delete link more

Question Tools

1 follower

Stats

Asked: 2016-05-29 07:06:43 -0600

Seen: 887 times

Last updated: May 29 '16