我正在使用 OpenCv
库在 python
中编写程序。我的项目文件夹是 Foo,里面有一个图像和可执行文件。我的 CmakeLists.txt
如下所示:
cmake_minimum_required(VERSION 2.8)
project(Foo)
find_package( OpenCV REQUIRED )
add_executable(Foo Im.py)
target_link_libraries(Foo ${OpenCV_LIBS} ${python2.7} )
当我执行 cmake .
时,出现以下错误:
-- Configuring done
CMake Error: CMake can not determine linker language for target: Foo
CMake Error: Cannot determine link language for target "Foo".
-- Generating done
-- Build files have been written to: /home/user_name/OpenCv/Foo
我正在使用 python 2.7 和 linux 16.04。
最佳答案
CMake 用于编译源代码(例如 C++ 或 C 代码)。
OpenCV 库可以与 C、C++ 或 Python 一起使用。 在这里,我猜想您希望将 Python 与 OpenCV 库一起使用,因此您不需要 CMake,因为 Python 是一种解释型语言,而不是像 C++ 这样的编译型语言。
您可以使用以下命令执行您的脚本:
python3 path/to/your/script.py
或者如果您使用该语言的早期版本(Python 2):
python2 path/to/your/script.py
关于python - 与 Python 和 OpenCv 链接,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45568762/