2017-08-08 71 views
0

我正在使用OpenCv库在python中编写程序。我的项目文件夹是Foo,里面有一个图像和可执行文件。我CmakeLists.txt看起来是这样的:与Python和OpenCv链接

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。

回答

0

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 
+0

没错,就是工作!谢谢! – Maria