I want compile and this example of OpenCV : https://docs.opencv.org/ref/master/d3/d50/group__imgproc__colormap.html
When I want to compile : g++ myfile.cxx -o myfile
I get this error :
fatal error opencv2/core.hpp not such file or directory
So I open the .bashrc and I add that : export PATH=${PATH}:/usr/local/include/opencv4 and when I compile I do now that : g++ myfile.cxx -o myfile -I/usr/include/opencv4
And now I get many error about undefined reference :
/usr/bin/ld : /tmp/ccISlbHF.o : dans la fonction « main » :
tryopencv.cxx:(.text+0xb1) : référence indéfinie vers « cv::imread(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, int) »
/usr/bin/ld : tryopencv.cxx:(.text+0x195) : référence indéfinie vers « cv::applyColorMap(cv::_InputArray const&, cv::_OutputArray const&, int) »
/usr/bin/ld : tryopencv.cxx:(.text+0x20e) : référence indéfinie vers « cv::imshow(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, cv::_InputArray const&) »
/usr/bin/ld : tryopencv.cxx:(.text+0x245) : référence indéfinie vers « cv::waitKey(int) »
/usr/bin/ld : /tmp/ccISlbHF.o : dans la fonction « cv::Mat::~Mat() » :
tryopencv.cxx:(.text._ZN2cv3MatD2Ev[_ZN2cv3MatD5Ev]+0x3d) : référence indéfinie vers « cv::fastFree(void*) »
/usr/bin/ld : /tmp/ccISlbHF.o : dans la fonction « cv::Mat::release() » :
tryopencv.cxx:(.text._ZN2cv3Mat7releaseEv[_ZN2cv3Mat7releaseEv]+0x4f) : référence indéfinie vers « cv::Mat::deallocate() »
collect2: error: ld returned 1 exit status
I search on many forums and many people speak about this : pkg-config opencv --cflags --libs
I need to put in this command opencv4 and not opencv because it doesn't work and with opencv4 I get this :
-I/usr/include/opencv4/opencv -I/usr/include/opencv4 -lopencv_stitching -lopencv_aruco -lopencv_bgsegm -lopencv_bioinspired -lopencv_ccalib -lopencv_dnn_objdetect -lopencv_dnn_superres -lopencv_dpm -lopencv_highgui -lopencv_face -lopencv_freetype -lopencv_fuzzy -lopencv_hdf -lopencv_hfs -lopencv_img_hash -lopencv_line_descriptor -lopencv_quality -lopencv_reg -lopencv_rgbd -lopencv_saliency -lopencv_shape -lopencv_stereo -lopencv_structured_light -lopencv_phase_unwrapping -lopencv_superres -lopencv_optflow -lopencv_surface_matching -lopencv_tracking -lopencv_datasets -lopencv_text -lopencv_dnn -lopencv_plot -lopencv_ml -lopencv_videostab -lopencv_videoio -lopencv_viz -lopencv_ximgproc -lopencv_video -lopencv_xobjdetect -lopencv_objdetect -lopencv_calib3d -lopencv_imgcodecs -lopencv_features2d -lopencv_flann -lopencv_xphoto -lopencv_photo -lopencv_imgproc -lopencv_core
I'm a little lost: How can I fix the problem to compile and test with OpenCV?