Ask Your Question

My code was compiling a month ago now it is giving so many errors

asked 2018-08-20 15:33:25 -0500

Sufyan gravatar image

i made a simple program using OPENCV library C:\fakepath\abcde.jpg It was working about a month ago now its giving me a lot of wierd Errors C:\fakepath\aaa.jpg

Thanks in Advance!

edit retag flag offensive close merge delete


please replace the useless screenshots with a text version, thank you.

berak gravatar imageberak ( 2018-08-20 20:14:57 -0500 )edit

sure !!!!

This was my code

#include <opencv2/opencv.hpp>
#include <vector>
int main()
    cv::Mat image1;
        cv::Mat image2;
    image1 = cv::imread("boldt.jpg");
    std::vector<cv::Mat> SplitChannel;
    SplitChannel[1] == 0;
    cv::namedWindow("NO GREEN CHANNEL");
    return 0;

and after compiliing it with g++ SplitImage -o Split it gives me following error

Sufyan gravatar imageSufyan ( 2018-08-21 05:26:52 -0500 )edit

/tmp/cc6muPV9.o: In function main': SplitChannel.cpp:(.text+0x67): undefined reference tocv::imread(cv::String const&, int)' SplitChannel.cpp:(.text+0xf8): undefined reference to cv::split(cv::_InputArray const&, cv::_OutputArray const&)' SplitChannel.cpp:(.text+0x143): undefined reference tocv::operator==(cv::Mat const&, double)' SplitChannel.cpp:(.text+0x19d): undefined reference to cv::merge(cv::_InputArray const&, cv::_OutputArray const&)' SplitChannel.cpp:(.text+0x1e3): undefined reference tocv::namedWindow(cv::String const&, int)' SplitChannel.cpp:(.text+0x238): undefined reference to cv::imshow(cv::String const&, cv::_InputArray const&)' SplitChannel.cpp:(.text+0x260): undefined reference tocv::waitKey(int)' /tmp/cc6muPV9.o: In function `c

Sufyan gravatar imageSufyan ( 2018-08-21 05:33:46 -0500 )edit

1 answer

Sort by ยป oldest newest most voted

answered 2018-08-21 04:34:19 -0500

kbarni gravatar image

You must link the OpenCV libs while building. Try:

g++ $(shell pkg-config opencv --libs) SplitChannel.cpp -o Split

The pkg-config opencv --libs command will return the list of OpenCV libraries.

edit flag offensive delete link more


Thanks!!! i tried running the above command but it gives me this error No command 'shell' found, did you mean:

Command 'spell' from package 'spell' (universe)
 Command 'shelr' from package 'shelr' (universe)
 Command 'jshell' from package 'openjdk-9-jdk-headless' (universe)
 Command 'bshell' from package 'avahi-ui-utils' (universe)
 Command 'lshell' from package 'lshell' (universe)
 Command 'pshell' from package 'python-pyramid' (universe)

shell: command not found

followed by all the previous errors

Sufyan gravatar imageSufyan ( 2018-08-21 05:25:09 -0500 )edit

ok, try with explicit libs then:

g++ SplitChannel.cpp -lopencv_core -lopencv_imgcodecs -lopencv_imgproc -lopencv_highgui  -o Split
berak gravatar imageberak ( 2018-08-21 05:43:05 -0500 )edit

Thanks!! All the previous errors are still there and now it is showing another one which is as below

In file included from /usr/local/include/opencv2/core.hpp:52:0,
                 from /usr/local/include/opencv2/opencv.hpp:52,
                 from SplitChannel.cpp:1:
/usr/local/include/opencv2/core/cvdef.h:440:4: error: #error "OpenCV 4.x+ requires enabled C++11 support"
 #  error "OpenCV 4.x+ requires enabled C++11 support"
Sufyan gravatar imageSufyan ( 2018-08-21 05:53:24 -0500 )edit

g++ -std=c++11

berak gravatar imageberak ( 2018-08-21 06:09:46 -0500 )edit

Great!!! i compiled it with above command and included the libraries exhibitly as you mentioned above and it compiled successfully but when i tried to run the executable file it gives me the following error

terminate called after throwing an instance of 'cv::Exception'
  what():  OpenCV(4.0.0-pre) /opt/opencv/modules/highgui/src/window.cpp:615: error: (-2:Unspecified error) The function is not implemented. Rebuild the library with Windows, GTK+ 2.x or Carbon support. If you are on Ubuntu or Debian, install libgtk2.0-dev and pkg-config, then re-run cmake or configure script in function 'cvNamedWindow'

Aborted (core dumped)
Sufyan gravatar imageSufyan ( 2018-08-21 06:18:16 -0500 )edit

unfortunately, it means, what the error says. your opencv libs were built without any gui support.

you'll have to get gtk or qt dev packages, and rebuild the oopencv libs with it.

berak gravatar imageberak ( 2018-08-21 06:20:42 -0500 )edit

Thanks for your Help sir!!

Sufyan gravatar imageSufyan ( 2018-08-21 06:40:33 -0500 )edit
Login/Signup to Answer

Question Tools

1 follower


Asked: 2018-08-20 15:33:25 -0500

Seen: 425 times

Last updated: Aug 21 '18