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