error adding symbols: File in wrong format collect2: error: ld returned 1 exit status

asked 2015-04-18 16:52:41 -0600

onitcales gravatar image

updated 2015-04-19 11:30:45 -0600

Escrevi este pequeno código para testar o uso do opencv.(I wrote this little code to test the opencv use.)

//teste.cpp-----------------------------------------------------------------------------
#include </usr/local/include/opencv/highgui.h>
int main(int argc, char** argv)
{
IplImage* img = cvLoadImage (argv[1]);
cvNamedWindow ("Exemplo 1", CV_WINDOW_AUTOSIZE);
cvShowImage ("Exemplo 1", img);
cvWaitKey(0);
cvReleaseImage(&img);
cvDestroyWindow("Exemplo 1");
}

Porém quando tento compilar no terminal, usando: (but when I try to build in terminal mode using:)

gcc -o teste teste.cpp pkg-config --libs opencv

recebo esta mensagem: (I received this message:) /usr/local/lib/libopencv_calib3d.so: error adding symbols: File in wrong format collect2: error: ld returned 1 exit status

como corrigir isso? ( how to fix this?)

edit retag flag offensive close merge delete

Comments

1

3 things wrong here:

  • your question is in chinese portugese, noone will be able to read it. ask in english, please.

  • you're trying to use C. this is no more possible, you will have to use C++. (use cv::Mat, and g++)

  • do not try to pass an absolute path with include, rather #include <opencv2/opencv.hpp>

berak gravatar imageberak ( 2015-04-19 01:00:58 -0600 )edit
2

Tank you Berak! I tranlate this via google!

onitcales gravatar imageonitcales ( 2015-04-19 11:36:20 -0600 )edit

btw, can you try to run pkg-config --libs opencv on the cmsline, to see what it outputs ?

i'm wondering, why it tried to link to an .so file instead of an .a

berak gravatar imageberak ( 2015-04-20 05:02:31 -0600 )edit