Qt Creator 错误:找不到 -lopencv_imgcodecs [英] Qt Creator Error: cannot find -lopencv_imgcodecs
问题描述
我已经通过 Windows 上的 VMware 在 ubuntu 15.10 上安装了 opencv、qt、qt creator、cmake.
I have installed opencv, qt, qt creator, cmake on ubuntu 15.10 through VMware on windows.
opencv安装在这个目录:/主页/majidalaeinia/opencv/
项目仓库被克隆到这个目录:/home/majidalaeinia/桌面/imgwarp-opencv/
我想通过它的 项目github.com/cxcxcxcx/imgwarp-opencv/blob/master/src/CMakeLists.txt" rel="nofollow noreferrer">CMakeLists.txt 在 qt Creator 中,当我按下 立即构建在 qt creator 上,我收到以下错误:
I want to run the project through its CMakeLists.txt in qt creator and when I press Build now on qt creator, I get the following errors:
error: cannot find -lopencv_imgcodecs
error: collect2: error: ld returned 1 exit status
问题出在哪里,我该如何解决?
Where is the problem and how can I solve it?
推荐答案
@ Majid Alaeinia,我上传了存储库并浏览了代码.如果你进入 demo
文件夹并用我在下面提供的文件更改当前的 CMakeLists.txt
文件,它应该编译(它确实在我提供的更改下编译):
@ Majid Alaeinia,I uploaded the repository and went through the code. if you go inside the demo
folder and you change the present CMakeLists.txt
file with the one I provided below it should compile (It does compile on mine with the provided changes):
project(demo)
cmake_minimum_required(VERSION 2.6)
find_package(Qt5 REQUIRED COMPONENTS Widgets Core)
FIND_PACKAGE( OpenCV REQUIRED )
include_directories(${QT_INCLUDES} ${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_SOURCE_DIR}/lib ${CMAKE_CURRENT_SOURCE_DIR})
set(demo_SRCS main.cpp projfile.cpp deformwin.cpp myimage.cpp singlephotoview.cpp pointspaint.cpp)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
set(CMAKE_INCLUDE_CURRENT_DIR ON)
#qt5_automoc(${demo_SRCS})
QT5_WRAP_CPP(QOBJ_CPP ${demo_SRCS})
qt5_wrap_ui(helloworld_FORMS_HEADERS deformwin.ui)
add_executable(demo ${demo_SRCS} ${helloworld_FORMS_HEADERS})
target_link_libraries(demo ${QT_QTCORE_LIBRARY} ${QT_QTGUI_LIBRARY} imgwarp-lib opencv_core opencv_imgproc opencv_imgcodecs)
存储库中的代码是旧代码,仍然带有 Qt4
作为主要包装器.我认为您的计算机上可能安装了 Qt5
,实际上我提供的代码适用于 Qt5
.将其用作 src
文件夹中存在的其他 CMakeLists.txt
文件的指南,并进行相应更改.
The code in the repository is an old code and still carries Qt4
as main wrappers. I think you probably have Qt5
installed on your computer and in fact the code I provided it will work for Qt5
. Use it as a guideline for the other CMakeLists.txt
file present inside src
folder and change accordingly.
CMake
会编译,但因为它使用了 Qt4
你需要找出最重要的模块来添加,例如包含 QtGui/的新标准QApplication
通常被替换为 QtWidgets/QApplication
CMake
will compile but because it was used Qt4
you need to figure out the most important modules to add, for example the new standard for including QtGui/QApplication
is usually substituted by QtWidgets/QApplication
我还想留下我之前的答案,以防您需要一个起点或初始模板.我希望这能澄清一点,并能让您继续推进您的项目.
I also wanted to leave my previous answer in case you need a starting point or a initial template. I hope this clarifies a bit more and can get you move forward for your project.
这篇关于Qt Creator 错误:找不到 -lopencv_imgcodecs的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!