9

i am using raspbian,opencv-2.4.8 and geany this is my simple/first code

#include <iostream>
#include <opencv2/highgui/highgui.hpp>
#include <opencv2/core/core.hpp>
using namespace std;
using namespace cv;
int main ()
{
    Mat image=imread("/home/pi/Desktop/pic3.png");
    if (! image.data)
    {
        cout<<"error"<<endl;
    }
    else
    {
        namedWindow("display",WINDOW_AUTOSIZE)
        imshow("display",image);
        waitKey(0);
        return 0;
    }
}    

these are compile and build commands in geany->project->properties->build

g++ $(pkg-config --cflags opencv-2.4.8) -c "f'
g++ $(pkg-config --clfags --libs opencv-2.4.8) -o "e" "f'

and it compiles and build perfectly but when i execute it this is my output

Illegal instruction


(program exited with code :132)

i have searched this exit code on internet but couldn't find a single thread or issue about it

2
  • If you put all warnings on, you should see, you're missing a return statement for your error path. Commented Jun 8, 2014 at 8:43
  • i added -Wall( for both compile and build) to enable warnings but still the same result Commented Jun 8, 2014 at 9:09

1 Answer 1

21

132 = 128 + 4

man exit:

>128   A command was interrupted by a signal.

man -s 7 signal

SIGILL        4       Core    Illegal Instruction

Later

The -I/usr/local/include -I/usrlocal/include/opencv makes sense for the compile-only (-c) call (but not for the second g++ call which links the executable). But libraries aren't specified by their full paths. What you normally do, is to specify one -L/usr/local/lib (or similar) for each directory, and -lopencv_calib3d (or similar) for each library in those directories (omitting lib and .so.)

Sign up to request clarification or add additional context in comments.

14 Comments

i am totally new to raspbian and i cant figure out why this error is generated even if i am using sample code of opencv same error appears any suggestion how to find/debug this error
i added sudo to my execute command now illegal instruction is gone but still gives program exited with code 132
The commands you give for building look very strange to me. For instance: "f'. The -c switch requests "compile only", so there should be an .o file, but this isn't used in the next command. So, I guess "e" (why the quotes?) is the executable, e, compiled and linked by the second command. - It is required to know what the $(pkg-config...) returns; library names should go to the end of the compile/link commands.
its for geany "f' compiles the file which is opened and "e" creats .o file with same name
pkg-config returns '-I/usr/local/include -I/usrlocal/include/opencv /usr/local/lib/libopencv_calib3d.so' and so on all .so files @laune
|

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.