[英]cmake error 'the source does not appear to contain CMakeLists.txt'
I'm installing opencv in ubuntu 16.04.我在 ubuntu 16.04 中安装 opencv。 After installing the necessary prerequisites I used the following command:-
安装必要的先决条件后,我使用了以下命令:-
kvs@Hunter:~/opencv_contrib$ mkdir build
kvs@Hunter:~/opencv_contrib$ cd build
kvs@Hunter:~/opencv_contrib/build$
kvs@Hunter:~/opencv_contrib/build$ cmake -D CMAKE_BUILD_TYPE=RELEASE -D CMAKE_INSTALL_PREFIX+/usr/local -D INSTALL_C_EXAMPLES=ON -D INSTALL_PYTHON_EXAMPLES=ON -D OPENCV_EXTRA_MODULES_PATH=~/opencv_contrib/modules -D BUILD_EXAMPLES=ON ..
but it produced an error:-但它产生了一个错误:-
CMake Error: The source directory "/home/kvs/opencv_contrib" does not appear to contain CMakeLists.txt.
Specify --help for usage, or press the help button on the CMake GUI.
I used the command provided in the folder 'module' documentation.我使用了文件夹“模块”文档中提供的命令。 How do I solve it?
我该如何解决? I tried the answers here at stack-overflow and a few other question but still can't figure it out.
我在stack-overflow和其他一些问题上尝试了答案,但仍然无法弄清楚。
You should do mkdir build
and cd build
while inside opencv
folder, not the opencv-contrib
folder.您应该在
opencv
文件夹中执行mkdir build
和cd build
而不是在opencv-contrib
文件夹中。 The CMakeLists.txt
is there. CMakeLists.txt
在那里。
Since you add ..
after cmake, it will jump up and up (just like cd ..
) in the directory.由于您在 cmake 之后添加
..
,它会在目录中向上跳跃(就像cd ..
)。 But if you want to run cmake under the same folder with CMakeLists.txt, please use .
但是如果你想在与 CMakeLists.txt 相同的文件夹下运行 cmake,请使用
.
instead of ..
.而不是
..
This reply may be late but it may help users having similar problem.此回复可能较晚,但可以帮助遇到类似问题的用户。 The opencv-contrib (available at https://github.com/opencv/opencv_contrib/releases ) contains extra modules but the build procedure has to be done from core opencv (available at from https://github.com/opencv/opencv/releases ) modules.
opencv-contrib(可从https://github.com/opencv/opencv_contrib/releases 获得)包含额外的模块,但构建过程必须从核心 opencv 完成(可从https://github.com/opencv/opencv 获得) /releases ) 模块。
Follow below steps (assuming you are building it using CMake GUI)按照以下步骤操作(假设您使用 CMake GUI 构建它)
Download openCV (from https://github.com/opencv/opencv/releases ) and unzip it somewhere on your computer.下载 openCV(从https://github.com/opencv/opencv/releases )并将其解压缩到您计算机上的某个位置。 Create build folder inside it
在其中创建构建文件夹
Download exra modules from OpenCV.从 OpenCV 下载 exra 模块。 (from https://github.com/opencv/opencv_contrib/releases ).
(来自https://github.com/opencv/opencv_contrib/releases )。 Ensure you download the same version.
确保您下载相同的版本。
Unzip the folder.解压文件夹。
Open CMake打开 CMake
Click Browse Source and navigate to your openCV folder.单击浏览源并导航到您的 openCV 文件夹。
Click Browse Build and navigate to your build Folder.单击浏览构建并导航到您的构建文件夹。
Click the configure button.单击配置按钮。 You will be asked how you would like to generate the files.
系统会询问您希望如何生成文件。 Choose Unix-Makefile from the drop down menu and Click OK.
从下拉菜单中选择 Unix-Makefile,然后单击 OK。 CMake will perform some tests and return a set of red boxes appear in the CMake Window.
CMake 将执行一些测试并返回一组出现在 CMake 窗口中的红色框。
Search for "OPENCV_EXTRA_MODULES_PATH" and provide the path to modules folder (eg /Users/purushottam_d/Programs/OpenCV3_4_5_contrib/modules)搜索“OPENCV_EXTRA_MODULES_PATH”并提供模块文件夹的路径(例如/Users/purushottam_d/Programs/OpenCV3_4_5_contrib/modules)
Click Configure again, then Click Generate.再次单击配置,然后单击生成。
Go to build folder转到构建文件夹
# cd build
# make
# sudo make install
I had a similar problem with another package and neither operating from a clean directory, to build from out, nor copy/paste the CMakeLists.txt file from the source to the clean directory worked.我在另一个 package 上遇到了类似的问题,既没有从干净的目录操作,也没有从外部构建,也没有将 CMakeLists.txt 文件从源复制/粘贴到干净的目录。 I simply solved installing by conda
我只是通过 conda 解决了安装问题
An easier way to build OpenCV from source in a step by step fashion as given in this reference: Installing OpenCV from the Source is to,一种更简单的方法来逐步从源代码构建 OpenCV,如本参考中给出的: 从源代码安装 OpenCV是,
step 1: install dependencies,第 1 步:安装依赖项,
sudo apt install build-essential cmake git pkg-config libgtk-
3-dev \libavcodec-dev libavformat-dev libswscale-dev
libv4l-dev \libxvidcore-dev libx264-dev libjpeg-dev
libpng-dev libtiff-dev \gfortran openexr libatlas-base-
dev python3-dev python3-numpy \libtbb2 libtbb-dev
libdc1394-22-dev
Step 2: create a directory opencv_build and Clone the necessary repositories as shown below,第 2 步:创建一个目录 opencv_build 并克隆必要的存储库,如下所示,
mkdir ~/opencv_build && cd ~/opencv_build
git clone https://github.com/opencv/opencv.git
git clone https://github.com/opencv/opencv_contrib.git
step 3: cd into opencv directory, inside create another directory called build and cd into it,第3步:cd进入opencv目录,在里面创建另一个名为build的目录,然后cd进去,
cd ~/opencv_build/opencv
mkdir build && cd build
step 4: evoke Cmake to build OpenCV,第 4 步:调用 Cmake 构建 OpenCV,
cmake -D CMAKE_BUILD_TYPE=RELEASE \
-D CMAKE_INSTALL_PREFIX=/usr/local \
-D INSTALL_C_EXAMPLES=ON \
-D INSTALL_PYTHON_EXAMPLES=ON \
-D OPENCV_GENERATE_PKGCONFIG=ON \
-D OPENCV_EXTRA_MODULES_PATH=~/opencv_build/opencv_contrib/modules \
-D BUILD_EXAMPLES=ON ..
If step 4 completes successfully you should see the following line at the end of the terminal, the build has been written to the directory created in step 3, along with the following lines above this line,如果步骤 4 成功完成,您应该在终端的末尾看到以下行,构建已写入步骤 3 中创建的目录,以及此行上方的以下几行,
configuration done generating done配置完成生成完成
step 5: To start the compilation process where -j is a flag for the number of the processor inside your machine, for example -j6 means we have 6 processors available.第 5 步:开始编译过程,其中 -j 是机器内部处理器数量的标志,例如 -j6 表示我们有 6 个处理器可用。 to verify the number of processors type nproc on the terminal then use this number after -j .
在终端上输入nproc来验证处理器的数量,然后在-j之后使用这个数字。 To start this process, we use the following command:
要开始此过程,我们使用以下命令:
make -j6
step 6: install OpenCV, We use,第 6 步:安装 OpenCV,我们使用,
sudo make install
then check the version Of OpenCV to verify the installation:然后检查OpenCV的版本以验证安装:
pkg-config --modversion opencv4
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.