1

I'm working on opencv implemented codes which I downloaded already by svn. These codes such as SIFT or SURF and codes for opencv were working perfectly before, but suddenly I got this error while I want to compile any code concerns opencv

/usr/lib/gcc/i486-linux-gnu/4.4.3/../../../../lib/crt1.o: In function `_start':
(.text+0x18): undefined reference to `main'
collect2: ld returned 1 exit status

So how can I solve it please, I have red already some problems but they were not helpful with my case, such as I have to change the compilation code from g++ SIFT.cpp -o SIFT .... to g++ -o SIFT SIFT.cpp .... but it didn't work out with me.

Thank you.

1
  • It would be difficult to help you without seeing the contents of SIFT.cpp. The problem is that you're attempting to link an executable with no main function defined. Commented Apr 14, 2011 at 1:15

2 Answers 2

6

I know this is old, but I just had a similar problem (with OpenCV 2.4.4a (and also 2.4.1)) and this was the first thing that popped up on google.

I disabled the "precompiled headers" option in the OpenCV configuration (do it from cmake-gui, or pass -DENABLE_PRECOMPILED_HEADERS=OFF to cmake when generating), and everything works fine.

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

Comments

1

main is the starting point of execution of any C++ program. And you probably have forgot to build the source file that has main function. Since the file you built doesn't has main, linker failed to find the starting point of execution.

g++ SIFT.cpp fileThatHasMainFunctionDefinition.cpp -o SIFT

or alternatively provide the main in SIFT.cpp itself.

2 Comments

The thing is, I did compile before and it was working very well and i got nice results and these programs are implemented already not me who did that, but now i got that. What do you think is the best to do? gcc sift.cpp pkg-config --libs --cflags opencv -o test this is how I compile
@Mario - I am not aware of openCV but the linker failed to find where main is all I can say from the error message. Sorry.

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.