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

查看:32
本文介绍了“不允许在源代码中构建";在 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天全站免登陆