burakim
burakim

Reputation: 482

opencv on ubuntu namespace cv error

Hi wen i build my code i get error message that is

./src/view.o: In function cv::Mat::MSize::MSize(int*)': /home/burak/desktop/workspace/deneme/Debug/../src/view.cpp:13: multiple definition ofmain' ./src/deneme.o:/home/burak/desktop/workspace/deneme/Debug/../src/deneme.cpp:12: first defined here collect2: error: ld returned 1 exit status make: * [deneme] Error 1

My code is

#include <opencv2/core/core.hpp> 
#include<opencv2/highgui/highgui.hpp>
#include<cv.h>
#include<iostream>

using namespace cv;
using namespace std;

int main( int argc, char** argv )
{
if( argc != 2)
{
 cout <<" Usage: display_image ImageToLoadAndDisplay" << endl;
 return -1;
}

Mat image;
image = imread(argv[1], CV_LOAD_IMAGE_COLOR);   // Read the file

if(! image.data )                              // Check for invalid input
{
    cout <<  "Could not open or find the image" << std::endl ;
    return -1;
}
///// Show Image... and main return 0 ///

how can i solve?

Upvotes: 0

Views: 1087

Answers (1)

Mario
Mario

Reputation: 36487

You've got two main() functions (one in view.cpp on line 13 and one in deneme.cpp on line 12). You can only have one main() function outside namespaces (i.e. as your entry point).

Upvotes: 1

Related Questions