How to contact Python3 Libs with cmake?

I have Python3 installed through brew install python3. However, cmakeit cannot find PythonLibs 3. Here is the title of mine CMakeLists.txt.

cmake_minimum_required(VERSION 3.0)
find_package(PythonLibs 3 REQUIRED)

When I started cmake, I got this error message

Could NOT find PythonLibs: Found unsuitable version "2.7.6", but required is at least "3" (found /usr/lib/libpython2.7.dylib)

Not sure what I did wrong.

+4
source share
2 answers

In my experience, this happened because I used an older version of cmake (2.8 instead of 3+) that did not know about Python 3.4 (it refused after 3.3.)

The solution was to go into the CMakeLists.txt file and add the Additional Versions directive ABOVE find_package:

set(Python_ADDITIONAL_VERSIONS 3.4) find_package(PythonLibs 3 REQUIRED)

, , cmake. cmake 2.8

+3

, CMake Python 3, brew OSX. , CMake , FindPythonLibs , , , .

, Python , , , , . Python, . Python , , 5 . . .

0

All Articles