DevCpp 上 OpenCV 2.3.1 中的链接器麻烦
关于我的环境的一些描述: 在 Windows Vista Home Premium SP1 32 位上使用 OpenCV 2.3.1 的 DevCpp 4.9.9.2
关于我的项目 - 我的项目的 .dev (FirstCVproj.dev) 文件位于 c:...\Desktop\proj\openCV\ 中,并且程序 i我正在尝试编译“faceDetect.cpp”位于 c:\opencv\samples\c
DevCpp 中的工具->编译器中的 OpenCV 编译器配置是:
编译器命令
-L"C:\opencv\build\x86\mingw\lib" -llibopencv_core231 -llibopencv_imgproc231 -llibopencv_calib3d231 -llibopencv_video231 -llibopencv_features2d231 -llibopencv_ml231 -llibopencv_highgui231 -llibopencv_objdetect231 -llibopencv_contrib231 -llibopencv_legacy231 -llibopencv_flann231
链接器命令
-llibopencv_core231 -llibopencv_imgproc231 -llibopencv_calib3d231 -llibopencv_video231 -llibopencv_features2d231 -llibopencv_ml231 -llibopencv_highgui231 -llibopencv_objdetect231 -llibopencv_contrib231 -llibopencv_legacy231 -llibopencv_flann231
库目录:opencv\build\x86\mingw\lib
二进制文件目录:opencv \build\x86\mingw\bin
包含目录:opencv 文件夹中的所有包含文件夹(在 \build 和主文件夹下)
所以在我决定在这里发布之前,我遇到了这里所述的问题并在那方面命令:
找不到libgcc_s_dw2_1.dll。尝试重新安装应用程序
libstdc++-6.dll 未找到。尝试重新安装应用程序 libstdc++-6.dll 未找到
因为使用 -static 或 -static-libgcc 或 -链接器命令行选项框中的 static-libstdc++ 对我不起作用,我将第一个 dll 文件从我发现它的系统中的其他目录复制到我的项目目录(并且在 mingw32 文件夹中不存在) C:\DevCpp) 并从网上下载了第二个,我的项目停止给出运行时错误,例如“FirsCVProj 已停止工作。请联系应用程序供应商寻求支持”或“未找到 .dll”
但情况变得更糟,因为在运行时,我确实看到了我在项目中编译的程序的命令输出窗口,但它只出现了不到一秒钟!
我重建了整个事情几次,但后来想起爱因斯坦的名言“重复同样的事情并期望不同的输出是疯狂的”我停了下来。 这就是你们进来的地方。这是编译日志,我不禁想知道为什么文件没有链接。
Compiler: OpenCV
Building Makefile: "C:\Users\ronnieaka\Desktop\PROJ\openCV\Makefile.win"
Executing make clean
rm -f ../../../../../opencv/samples/c/facedetect.o FirstCVproj.exe
g++.exe -c ../../../../../opencv/samples/c/facedetect.cpp -o ../../../../../opencv/samples/c/facedetect.o -I"lib/gcc/mingw32/3.4.2/include" -I"include/c++/3.4.2/backward" -I"include/c++/3.4.2/mingw32" -I"include/c++/3.4.2" -I"include" -I"C:/opencv/include" -I"C:/opencv/include/opencv" -I"C:/opencv/include/opencv2" -I"C:/opencv/build/include" -I"C:/opencv/build/include/opencv" -I"C:/opencv/build/include/opencv2" -L"C:\opencv\build\x86\mingw\lib" -llibopencv_core231 -llibopencv_imgproc231 -llibopencv_calib3d231 -llibopencv_video231 -llibopencv_features2d231 -llibopencv_ml231 -llibopencv_highgui231 -llibopencv_objdetect231 -llibopencv_contrib231 -llibopencv_legacy231 -llibopencv_flann231
g++.exe: -llibopencv_core231: linker input file unused because linking not done
g++.exe: -llibopencv_imgproc231: linker input file unused because linking not done
g++.exe: -llibopencv_calib3d231: linker input file unused because linking not done
g++.exe: -llibopencv_video231: linker input file unused because linking not done
g++.exe: -llibopencv_features2d231: linker input file unused because linking not done
g++.exe: -llibopencv_ml231: linker input file unused because linking not done
g++.exe: -llibopencv_highgui231: linker input file unused because linking not done
g++.exe: -llibopencv_objdetect231: linker input file unused because linking not done
g++.exe: -llibopencv_contrib231: linker input file unused because linking not done
g++.exe: -llibopencv_legacy231: linker input file unused because linking not done
g++.exe: -llibopencv_flann231: linker input file unused because linking not done
g++.exe ../../../../../opencv/samples/c/facedetect.o -o "FirstCVproj.exe" -L"lib" -L"C:/opencv/build/x86/mingw/lib" -llibopencv_core231 -llibopencv_imgproc231 -llibopencv_calib3d231 -llibopencv_video231 -llibopencv_features2d231 -llibopencv_ml231 -llibopencv_highgui231 -llibopencv_objdetect231 -llibopencv_contrib231 -llibopencv_legacy231 -llibopencv_flann231
Execution terminated
Compilation successful
编辑:
我还尝试了 opencv\samples\c\mushroom.cpp ,我得到了输出窗口,其中打印了程序的详细信息、关于其作者等,但随后我收到了 Windows 消息:“FirstCVproj 已停止工作”
A little description about my environment:
DevCpp 4.9.9.2 with OpenCV 2.3.1 on Windows Vista Home Premium SP1 32-bit
About my project - my project's .dev (FirstCVproj.dev) file is in c:...\Desktop\proj\openCV\ and the program i'm trying to compile "facedetect.cpp" is in c:\opencv\samples\c
The OpenCV compiler configuration in the tools->compilers in DevCpp is:
Compiler commands
-L"C:\opencv\build\x86\mingw\lib" -llibopencv_core231 -llibopencv_imgproc231 -llibopencv_calib3d231 -llibopencv_video231 -llibopencv_features2d231 -llibopencv_ml231 -llibopencv_highgui231 -llibopencv_objdetect231 -llibopencv_contrib231 -llibopencv_legacy231 -llibopencv_flann231
Linker commands
-llibopencv_core231 -llibopencv_imgproc231 -llibopencv_calib3d231 -llibopencv_video231 -llibopencv_features2d231 -llibopencv_ml231 -llibopencv_highgui231 -llibopencv_objdetect231 -llibopencv_contrib231 -llibopencv_legacy231 -llibopencv_flann231
Libraries directory: opencv\build\x86\mingw\lib
Binaries directory: opencv\build\x86\mingw\bin
Include directories: all the include folders in opencv folder (under the \build and the main folder)
So before I decided to post here, i was having the problems stated here and in that order:
libgcc_s_dw2_1.dll not found. Try reinstalling the application
Program can't find libgcc_s_dw2-1.dll
libstdc++-6.dll not found. Try reinstalling the application
libstdc++-6.dll not found
Because using -static or -static-libgcc or -static-libstdc++ in linker command line options box did not work for me, i copied the first dll file to my project directory from some other directory in my system where i found it (and nowhere in mingw32 folder in C:\DevCpp) and downloaded the second one off the net, my project stopped giving run-time errors like "FirsCVProj has stopped working. Contact the application vendor for support" or ".dll was not found"
But it became worse, because at runtime, i did see the command output window of the program i was compiling in my project, but that just appeared for like a fraction of a second!
I rebuild the whole thing a couple of times, but then remembering Einstein's quote "Repeating the same thing and expecting a different output is insanity" i stopped..
That's where you guys come in. Here's the compilation log from which i can't help wondering why the files aren't linking.
Compiler: OpenCV
Building Makefile: "C:\Users\ronnieaka\Desktop\PROJ\openCV\Makefile.win"
Executing make clean
rm -f ../../../../../opencv/samples/c/facedetect.o FirstCVproj.exe
g++.exe -c ../../../../../opencv/samples/c/facedetect.cpp -o ../../../../../opencv/samples/c/facedetect.o -I"lib/gcc/mingw32/3.4.2/include" -I"include/c++/3.4.2/backward" -I"include/c++/3.4.2/mingw32" -I"include/c++/3.4.2" -I"include" -I"C:/opencv/include" -I"C:/opencv/include/opencv" -I"C:/opencv/include/opencv2" -I"C:/opencv/build/include" -I"C:/opencv/build/include/opencv" -I"C:/opencv/build/include/opencv2" -L"C:\opencv\build\x86\mingw\lib" -llibopencv_core231 -llibopencv_imgproc231 -llibopencv_calib3d231 -llibopencv_video231 -llibopencv_features2d231 -llibopencv_ml231 -llibopencv_highgui231 -llibopencv_objdetect231 -llibopencv_contrib231 -llibopencv_legacy231 -llibopencv_flann231
g++.exe: -llibopencv_core231: linker input file unused because linking not done
g++.exe: -llibopencv_imgproc231: linker input file unused because linking not done
g++.exe: -llibopencv_calib3d231: linker input file unused because linking not done
g++.exe: -llibopencv_video231: linker input file unused because linking not done
g++.exe: -llibopencv_features2d231: linker input file unused because linking not done
g++.exe: -llibopencv_ml231: linker input file unused because linking not done
g++.exe: -llibopencv_highgui231: linker input file unused because linking not done
g++.exe: -llibopencv_objdetect231: linker input file unused because linking not done
g++.exe: -llibopencv_contrib231: linker input file unused because linking not done
g++.exe: -llibopencv_legacy231: linker input file unused because linking not done
g++.exe: -llibopencv_flann231: linker input file unused because linking not done
g++.exe ../../../../../opencv/samples/c/facedetect.o -o "FirstCVproj.exe" -L"lib" -L"C:/opencv/build/x86/mingw/lib" -llibopencv_core231 -llibopencv_imgproc231 -llibopencv_calib3d231 -llibopencv_video231 -llibopencv_features2d231 -llibopencv_ml231 -llibopencv_highgui231 -llibopencv_objdetect231 -llibopencv_contrib231 -llibopencv_legacy231 -llibopencv_flann231
Execution terminated
Compilation successful
EDIT:
i also tried opencv\samples\c\mushroom.cpp and i got the output window in which the details of the program were printed, about its author etc, but then i got the windows message: "FirstCVproj has stopped working"
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
可以在命令行中看到您正在添加此路径作为库路径:
您需要通过确认可以在其中找到所有这些文件来确保这是正确的目录:
我不'没有安装 Dev-C++,我也不推荐它。最新发布的正式版本可以追溯到2005年2月22日:
我强烈建议您转向另一个编译器,如果您考虑使用 Visual Studio Express(免费),您可以按照本教程配置 OpenCV。
编辑:
您应该添加的库目录是包含.a文件的目录,并且它可能与包含DLL的目录不同。请记住,DLL 在应用程序执行时使用,而不是在应用程序处于构建(链接)过程中时使用。
编辑:
不要将库文件包含为
-llibopencv_core231
,而是将其包含为-lopencv_core231
。It's possible to see in the command line that you are adding this path as the libraries path:
You need to make sure this is right directory by confirming that all these files can be found in there:
I don't have Dev-C++ installed nor I recommend it. The last official version released dates back to February 22, 2005:
I strongly suggest you move to another compiler, if you consider Visual Studio Express (which is free) you can follow this tutorial to configure OpenCV.
EDIT:
The library directory you should be adding it's the one that has .a files, and it may not be same as the one that has the DLLs. Remember, DLLs are used when the application is executed and not when the application is in the building (linkage) process.
EDIT:
Don't include the library files as
-llibopencv_core231
, do it as-lopencv_core231
.