问题描述
我安装了 Qt 5.10 最新版本和 opencv3.4.1 ,但是我无法使用 Cmake 在此版本的Qt中安装该库.有人可以帮助我在Windows 10 64位系统上执行此操作吗?我也尝试过这部影片 https://www.youtube.com/watch?v=ZOSu-2Oju- A 在cmd步骤中我有这个(此链接中的图片)时我所拥有的
在此链接中也((( https://wiki.qt.io/How_to_setup_Qt_and_openCV_on_Windows ))我仔细地完成了所有步骤,但是在执行完这些步骤之后,我在opencv-build中没有找到文件夹bin,并且我的操作系统是Windows 10 64位,感谢您的帮助.
注意:我的回答更多地基于(发布的 .pdf 中提到的工具版本)
1.初步考虑
一开始,我尝试使用计算机上的现有产品( Win 10 )进行构建:
- CMake 3.6.4 (由 Android Studio 捆绑-我已经几个月没有更新了 BTW ), cmdline -因为没有 GUI
- MinGW7.2.0 (我在机器上构建的用于其他任务)
- g ++ 7.2.0
- OpenCV 3.4.2 (下载的 [GitHub ]:opencv/opencv-opencv-3.4.2.zip ,专门用于此任务)
构建过程已通过此阶段(嗯,在此点以下它失败了,我没有检查到底是为什么).无论如何,我认为我使用的构建环境与建议的构建环境相距太远,所以我:
- 下载的 CMake 3.6.3 Win x64 软件包(包含 cmake-gui -作为 cmdline 可以痛苦,尤其是对于那些不习惯的人)
- 使用了 MinGW 5.3.0 (我的 Qt 安装的一部分)
- g ++ 5.3.0
问题的核心(如注释中所述,或由 Google 指定错误)是 g ++ 编译器未使用 C ++ 11 标准(并且 protobuf 源代码需要它).
因此,我做了一些测试:将错误代码粘贴到文件中(并添加了虚拟 main ),并在2个 MinGW 安装中进行了尝试. /p>
code.cpp :
template <typename char_type>
bool null_or_empty(const char_type* s) {
return s == nullptr || *s == 0;
}
int main() {
return 0;
}
输出:
如图所示,较早的 g ++ 需要-std=c++0x
明确.
在构建步骤之后,出现了与下图相同的错误(我直接在 protobuf 的目录中启动了 mingw32-make 之前建立的东西):
2.解决方案
这两者都是在 cmake-gui 级别完成的.设置路径后:
- 点击"配置"
- 进行所需的变量更改
- 点击"生成" 从控制台
- 在构建目录中启动 mingw32-make
注释:
-
由于我距离成为 CMake 专家还很遥远,因此在执行此操作之前,我先清空构建目录,以确保以前的构建没有剩余(当然,缺点是是所有操作都需要再次完成,通常需要很长时间)
-
因为我没有启用并行构建,所以我没有等待完整的构建完成(因为这需要很长时间),而只是检查它是否通过了这一点
2.1强制 C ++ 11 标准
点击"添加条目"并设置 [CMake 3.1]:CXX_STANDARD :
在下面,请注意,构建通过之前失败的地方:
2.2跳过 protobuf 构建
注释:
- 在已发布的电影中,没有尝试进行 protobuf 构建(可能不在捆绑包中?),这就是为什么不会弹出该错误的原因
- 我不知道最终版本中将不提供哪些功能,因为我不知道 使用了什么 protobuf
- 我认为这更像是一种解决方法
搜索与 protobuf 相关的变量,并取消选中任何在 BUILD 或 WITH 组中的变量( 蓝色行):
同样的效果在下面- protobuf 构建不再发生(它紧随 libIlmImf 之后):
I install Qt 5.10 latest version and opencv3.4.1 and I couldn't install the library in this version of Qt with Cmake can anybody help me to do it on my windows 10 64-bit please?I tried with this video alsohttps://www.youtube.com/watch?v=ZOSu-2Oju-Aand in cmd step I have this (picture in this link)
in this link also (( https://wiki.qt.io/How_to_setup_Qt_and_openCV_on_Windows )) I do all steps carefully but I didn't found the folder bin in opencv-build after do the steps and My OS is windows 10 64-bit thanks for help.
Note: I'm basing my answer more on [SO]: openCV mingw-32 error in cmd (the tools versions mentioned in the posted .pdf)
1. Preliminary considerations
At the beginning, I tried to build it using what I already had on my machine (Win 10):
- CMake 3.6.4 (bundled by Android Studio - that I didn't updated for months BTW), cmdline - as there's no GUI
- MinGW7.2.0 (that I built on my machine for a different task)
- g++ 7.2.0
- OpenCV 3.4.2 (downloaded [GitHub]: opencv/opencv - opencv-3.4.2.zip, specifically for this task)
The build process passed this stage (well, it failed somewhere below this point, I didn't check why exactly).Anyway, I thought that the build env that I used, and the suggested one were too far away, so I:
- Downloaded CMake 3.6.3 Win x64 bundle (that contains cmake-gui - as cmdline can be a pain, especially for those that are not used to it)
- Used MinGW 5.3.0 (part of my Qt installation)
- g++ 5.3.0
The problem at its core (as specified in comments, or Googleing the error) is that the g++ compiler doesn't use the C++11 standard (and protobuf source code requires it).
So, I did a little test: pasted the faulty code in a file (and added a dummy main), and tried it with the 2 MinGW installations.
code.cpp:
template <typename char_type>
bool null_or_empty(const char_type* s) {
return s == nullptr || *s == 0;
}
int main() {
return 0;
}
Output:
As seen, the older g++ needs -std=c++0x
explicitly.
Following the build steps, I got the same error as in the image below (I launched mingw32-make directly in protobuf's dir, to skip all the other stuff built before it):
2. Solutions
Both are done at cmake-gui level. After setting the paths:
- Hit "Configure"
- Do the required variable changes
- Hit "Generate"
- Launch mingw32-make from console, in the build dir
Notes:
Since I'm very far away from being a CMake expert, before doing this, I empty the build dir to make sure that there's nothing left from previous build (of course the drawback is that everything is done again, which usually takes a long time)
Since I didn't enable parallel build, I didn't wait for the full build to finish (as it takes forever), but just checked that it passes this point
2.1 Force C++11 standard
Click "Add Entry" and set [CMake 3.1]: CXX_STANDARD:
And below, notice that the build passed point where it was failing before:
2.2 Skip protobuf build
Notes:
- In the posted movie, there's no protobuf build attempted (probably it's not in the bundle?) that's why this error didn't pop up
- I don't know what functionality will not be available in the final build, as I don't know what protobuf is used at
- I consider this more like a workaround
Search for protobuf related variables, and uncheck any that are in the BUILD or WITH groups (the blue lines):
And again the effect is below - the protobuf build no longer takes place (it comes just after libIlmImf):
这篇关于使用CMAKE安装opencv 3.4.1和Qt 5.10的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!