【问题标题】:Linking with Python and OpenCv与 Python 和 OpenCv 链接
【发布时间】:2017-08-08 12:44:57
【问题描述】:

我正在使用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。

【问题讨论】:

    标签: python linux opencv cmake


    【解决方案1】:

    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
    

    【讨论】:

      猜你喜欢
      • 2013-11-12
      • 2013-02-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-04-17
      • 1970-01-01
      相关资源
      最近更新 更多