“不允许源内构建";在cmake中 [英] "In-source builds are not allowed" in cmake

查看:347
本文介绍了“不允许源内构建";在cmake中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是cmake的新手,我只是用它在我的ubuntu linux上安装opencv. 这是我运行的命令:

I'm new to cmake, and I'm only using it to install opencv on my ubuntu linux. Here's the command I ran:

"cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=/home/jinha/OCV/source"

然后返回错误:

"FATAL: In-source builds are not allowed.
You should create separate directory for build files."

我当前的目录/home/jinha/OCV/build/opencv确实包含CMakefiles.txt文件,所以这不是问题.我试图在命令中更改目录,但是它们都引发相同的错误.我看到了有关此问题的其他答案,因此每次运行命令之前,我都会擦除CMakeFiles文件夹和CMakeCache.txt文件,但是它们都不起作用.谢谢.

My current directory, /home/jinha/OCV/build/opencv, does contain the CMakefiles.txt file, so that's not the problem. I tried to change the directory in my command, but they all raise the same error. I saw the other answers on this issue, so I erased CMakeFiles folder and CMakeCache.txt file every time before I ran the command, but none of them worked. Thanks.

推荐答案

它希望您在任何地方创建一个单独的构建目录,然后在其中运行cmake.例如:

It wants you to create a separate build directory (anywhere), and run cmake there. For example:

mkdir my_build_dir
cd my_build_dir
rm ../CMakeCache.txt
cmake .. -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=/home/jinha/OCV/source

请注意本示例中的..,它告诉cmake在哪里寻找源.

Note the .. in this example telling cmake where to look for the source.

如果您在重新构建之前没有删除CMakeCache.txt,它仍然会显示此错误. 因此,请记住在运行cmake之前先删除CMakeCache.txt.

In case you didn't remove CMakeCache.txt before building again, it will still show this error. So, please remember to delete CMakeCache.txt first before running cmake.

这篇关于“不允许源内构建";在cmake中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆