main.cpp:(.text+0x51): undefined reference to `cv::imread(std::__cxx11::basic_string, std::allocator > const&, int)'
That means, you're not linking some required lib,
(in your case, ALL of the opencv libs are missing from the cmdline !)
try again with:
g++ main.cpp -I/opt/robots/pepper/ctc-linux64-atom-2.5.10.7/opencv2/include/ -L/opt/robots/pepper/ctc-linux64-atom-2.5.10.7/opencv2/lib -lopencv_core -lopencv_highgui -lopencv_imgcodecs -lopencv_imgproc -lopencv_videoio
main.cpp:(.text+0x51): undefined reference to `cv::imread(std::__cxx11::basic_string, std::allocator > const&, int)'
--> My custom command that live sin my /usr/bin folder , that runs my cv2 cpp files just fine without any problems
--> that may help someone
#!/bin/bash
file=$@
if [ "${file: -4}" = ".cpp" ]; then
g++ $file -I/opt/robots/pepper/ctc-linux64-atom-2.5.10.7/opencv2/include/ -L/opt/robots/pepper/ctc-linux64-atom-2.5.10.7/opencv2/lib -lopencv_core -lopencv_highgui -lopencv_imgcodecs -lopencv_imgproc -lopencv_videoio
if $status ; then
./a.out && rm -rf a.out
fi
else
echo "This Command should be used only with cpp files that uses the opencv library !!"
fi
|