Ask Your Question
0

Problem Building a Project in Eclipse [Ubuntu]

asked Aug 2 '12

NickOS gravatar image

Hello,

I followed exactly the tutorial in http://docs.opencv.org/doc/tutorials/introduction/linux_eclipse/linux_eclipse.html#linux-eclipse-usage

and when I tried to build the project I created, I got 2 errors in the console:

Building target: Test
Invoking: GCC C++ Linker
g++ -L/usr/local/lib -o"Test" ./src/Test.o -lopencv_core -lopencv_highgui -lopencv_legacy -lopencv_ml -lopencv_video -lopencv_contrib -lopencv_features2d -lopencv_imgproc -lopencv_calib3d -lopencv_objdetect -lopencv_flann
/usr/lib/gcc/x86_64-linux-gnu/4.6/../../../x86_64-linux-gnu/crt1.o: In function `_start':

(.text+0x20): undefined reference to `main'
collect2: ld returned 1 exit status
make: *** [Test] Error 1

What seems to be the problem?

Thanks, in advance.

Preview: (hide)

Comments

Dear NickOS,

Did you solve the problem cause i have the same problem and cannot find a solution. I have tried numerous methods and I followed the opencv tutorial exactly as you did.

Any help will be much appreciated since i am stuck and I cannot proceed.

Best Regards, Robert Grech

Robert_Grech gravatar imageRobert_Grech (Oct 30 '13)edit

2 answers

Sort by » oldest newest most voted
1

answered Aug 2 '12

jasedit gravatar image

What are the contents of Test.cpp? It is reporting it can't find the definition of the main() function - without seeing the contents of Test.cpp as you have it saved on disk, it's hard to tell for certain what's going wrong.

The signature of main() could be wrong, or an errant semicolon could be making the definition not be found. Or main() could be in another file altogether that isn't being linked into Test. Without seeing Test.cpp I can't be certain what's going wrong.

Preview: (hide)

Comments

Thank you for your interest, and sorry if I wasn't clear. The Test.cpp has the code snippet from the tutorial I mentioned before:

#include <cv.h>
#include <highgui.h>

using namespace cv;

int main( int argc, char** argv )
{
  Mat image;
  image = imread( argv[1], 1 );

  if( argc != 2 || !image.data )
    {
      printf( "No image data \n" );
      return -1;
        }

  namedWindow( "Display Image", CV_WINDOW_AUTOSIZE );
  imshow( "Display Image", image );

  waitKey(0);

  return 0;
}
NickOS gravatar imageNickOS (Aug 3 '12)edit
0

answered Jun 23 '14

shruti gravatar image

Dear NickOS, you have not included this header file

include <iostream>

your problem will be solved and if not please again check if you have included and given correct path to libraries.

Thank you

Preview: (hide)

Question Tools

Stats

Asked: Aug 2 '12

Seen: 1,459 times

Last updated: Jun 23 '14