简体   繁体   English

编译错误opencv

[英]Compiling error opencv

I'm working on opencv implemented codes which I downloaded already by svn. 我正在研究opencv实现的代码,这些代码已由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 这些代码(例如SIFT或SURF以及opencv的代码)以前运行良好,但是突然间我在编译任何与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. 因此,请问如何解决,我已经遇到了一些问题,但对我的情况没有帮助,例如,我必须将编译代码从g++ SIFT.cpp -o SIFT ....更改为g++ -o SIFT SIFT.cpp ....但我不满意。

Thank you. 谢谢。

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. 我知道这很旧,但是我也遇到了类似的问题(使用OpenCV 2.4.4a(以及2.4.1)),这是在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. 我在OpenCV配置中禁用了“预编译头”选项(从cmake-gui ,或者在生成时将-DENABLE_PRECOMPILED_HEADERS=OFF传递给cmake ),并且一切正常。

main is the starting point of execution of any C++ program. main是任何C ++程序执行的起点。 And you probably have forgot to build the source file that has main function. 而且您可能忘记了构建具有main功能的源文件。 Since the file you built doesn't has main , linker failed to find the starting point of execution. 由于您构建的文件没有main ,因此链接程序无法找到执行的起点。

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

or alternatively provide the main in SIFT.cpp itself. 或者在SIFT.cpp本身中提供main

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM