Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cmake version 3.12 and greater cannot find PythonInterp #556

Closed
TheElementalOfDestruction opened this issue Apr 20, 2019 · 10 comments
Closed

Comments

@TheElementalOfDestruction

Cmake version 3.12 and greater cannot find PythonInterp. Variable has been changed to simply Python in version 3.12.

See https://stackoverflow.com/a/53368098/7723054 for more details

@s3rvac
Copy link
Member

s3rvac commented Apr 21, 2019

This is strange. I use CMake 3.14 on Arch Linux and have no issues with finding PythonInterp:

build $ cmake ..
[..]
-- Found PythonInterp: /usr/bin/python3 (found suitable version "3.7.3", minimum required is "3.4")
[..]

I have also tried building RetDec in Docker on Ubuntu 18.10 that has CMake 3.12 and had no issues with PythonInterp.

To be able to reproduce the issue, can you please provide the following information?

  • What OS and version do you use?
  • If you use MS Windows, are you trying to build RetDec directly in it (recommended) or via WSL/Cygwin/MSYS or a similar environment?
  • What cmake command did you run (including all arguments)?
  • What is the output (complete one)?

@s3rvac
Copy link
Member

s3rvac commented Apr 21, 2019

BTW, CMake 3.12 has made FindPythonInterp deprecated. This does not mean it is completely gone. It just means that it should not be used in new projects that require CMake >= 3.12. The minimal required version of CMake in RetDec is 3.6.

@TheElementalOfDestruction
Copy link
Author

Unfortunately, in my copy of visual studio, cmake does not understand it properly at all, and somehow only finds a python version 1.4 or something, a version which DEFINITELY does not exist on my system.

Os: Windows 10
Method: Visual studio 2017
Cmake command: Whatever the heck visual studio uses. I don't actually know. Edit: Oh, it's this:

c:\program files (x86)\microsoft visual studio\2017\community\common7\ide\commonextensions\microsoft\cmake\CMake\bin\cmake.exe  -G "Ninja" -DCMAKE_INSTALL_PREFIX:PATH="C:\Users\Creation\CMakeBuilds\7266e1f7-ff79-8434-8194-ef100ebd5298\install\x64-Debug (default)"  -DCMAKE_CXX_COMPILER="C:/Program Files (x86)/Microsoft Visual Studio/2017/Community/VC/Tools/MSVC/14.16.27023/bin/HostX64/x64/cl.exe"  -DCMAKE_C_COMPILER="C:/Program Files (x86)/Microsoft Visual Studio/2017/Community/VC/Tools/MSVC/14.16.27023/bin/HostX64/x64/cl.exe"  -DCMAKE_BUILD_TYPE="Debug" -DCMAKE_MAKE_PROGRAM="c:\program files (x86)\microsoft visual studio\2017\community\common7\ide\commonextensions\microsoft\cmake\Ninja\ninja.exe" "C:\Users\Creation\Downloads\git\retdec-vs"

Complete Output:

1> Command line: c:\program files (x86)\microsoft visual studio\2017\community\common7\ide\commonextensions\microsoft\cmake\CMake\bin\cmake.exe  -G "Ninja" -DCMAKE_INSTALL_PREFIX:PATH="C:\Users\Creation\CMakeBuilds\7266e1f7-ff79-8434-8194-ef100ebd5298\install\x64-Debug (default)"  -DCMAKE_CXX_COMPILER="C:/Program Files (x86)/Microsoft Visual Studio/2017/Community/VC/Tools/MSVC/14.16.27023/bin/HostX64/x64/cl.exe"  -DCMAKE_C_COMPILER="C:/Program Files (x86)/Microsoft Visual Studio/2017/Community/VC/Tools/MSVC/14.16.27023/bin/HostX64/x64/cl.exe"  -DCMAKE_BUILD_TYPE="Debug" -DCMAKE_MAKE_PROGRAM="c:\program files (x86)\microsoft visual studio\2017\community\common7\ide\commonextensions\microsoft\cmake\Ninja\ninja.exe" "C:\Users\Creation\Downloads\git\retdec-vs"
1> Working directory: C:\Users\Creation\CMakeBuilds\7266e1f7-ff79-8434-8194-ef100ebd5298\build\x64-Debug (default)
1> -- The C compiler identification is MSVC 19.16.27030.1
1> -- The CXX compiler identification is MSVC 19.16.27030.1
1> -- Check for working C compiler: C:/Program Files (x86)/Microsoft Visual Studio/2017/Community/VC/Tools/MSVC/14.16.27023/bin/HostX64/x64/cl.exe
1> -- Check for working C compiler: C:/Program Files (x86)/Microsoft Visual Studio/2017/Community/VC/Tools/MSVC/14.16.27023/bin/HostX64/x64/cl.exe -- works
1> -- Detecting C compiler ABI info
1> -- Detecting C compiler ABI info - done
1> -- Detecting C compile features
1> -- Detecting C compile features - done
1> -- Check for working CXX compiler: C:/Program Files (x86)/Microsoft Visual Studio/2017/Community/VC/Tools/MSVC/14.16.27023/bin/HostX64/x64/cl.exe
1> -- Check for working CXX compiler: C:/Program Files (x86)/Microsoft Visual Studio/2017/Community/VC/Tools/MSVC/14.16.27023/bin/HostX64/x64/cl.exe -- works
1> -- Detecting CXX compiler ABI info
1> -- Detecting CXX compiler ABI info - done
1> -- Detecting CXX compile features
1> -- Detecting CXX compile features - done
1> -- Configuring incomplete, errors occurred!
1> See also "C:/Users/Creation/CMakeBuilds/7266e1f7-ff79-8434-8194-ef100ebd5298/build/x64-Debug (default)/CMakeFiles/CMakeOutput.log".
1> CMake Error at C:/Program Files (x86)/Microsoft Visual Studio/2017/Community/Common7/IDE/CommonExtensions/Microsoft/CMake/CMake/share/cmake-3.12/Modules/FindPackageHandleStandardArgs.cmake:137 (message):
1>   Could NOT find PythonInterp: Found unsuitable version "1.4", but required
1>   is at least "3.4" (found C:/cygwin64/bin/python3)
1> Call Stack (most recent call first):
1>   C:/Program Files (x86)/Microsoft Visual Studio/2017/Community/Common7/IDE/CommonExtensions/Microsoft/CMake/CMake/share/cmake-3.12/Modules/FindPackageHandleStandardArgs.cmake(376): (_FPHSA_FAILURE_MESSAGE)
1>   C:/Program Files (x86)/Microsoft Visual Studio/2017/Community/Common7/IDE/CommonExtensions/Microsoft/CMake/CMake/share/cmake-3.12/Modules/FindPythonInterp.cmake(159): (FIND_PACKAGE_HANDLE_STANDARD_ARGS)
1>   C:\Users\Creation\Downloads\git\retdec-vs\CMakeLists.txt(22): (find_package)
1> 
1> 
1> c:\program files (x86)\microsoft visual studio\2017\community\common7\ide\commonextensions\microsoft\cmake\CMake\bin\cmake.exe  -G "Ninja" -DCMAKE_INSTALL_PREFIX:PATH="C:\Users\Creation\CMakeBuilds\7266e1f7-ff79-8434-8194-ef100ebd5298\install\x64-Debug (default)"  -DCMAKE_CXX_COMPILER="C:/Program Files (x86)/Microsoft Visual Studio/2017/Community/VC/Tools/MSVC/14.16.27023/bin/HostX64/x64/cl.exe"  -DCMAKE_C_COMPILER="C:/Program Files (x86)/Microsoft Visual Studio/2017/Community/VC/Tools/MSVC/14.16.27023/bin/HostX64/x64/cl.exe"  -DCMAKE_BUILD_TYPE="Debug" -DCMAKE_MAKE_PROGRAM="c:\program files (x86)\microsoft visual studio\2017\community\common7\ide\commonextensions\microsoft\cmake\Ninja\ninja.exe" "C:\Users\Creation\Downloads\git\retdec-vs" returned with exit code: 1
CMake Error at C:/Program Files (x86)/Microsoft Visual Studio/2017/Community/Common7/IDE/CommonExtensions/Microsoft/CMake/CMake/share/cmake-3.12/Modules/FindPackageHandleStandardArgs.cmake:137 (message):
  Could NOT find PythonInterp: Found unsuitable version "1.4", but required
  is at least "3.4" (found C:/cygwin64/bin/python3)
Call Stack (most recent call first):
  C:/Program Files (x86)/Microsoft Visual Studio/2017/Community/Common7/IDE/CommonExtensions/Microsoft/CMake/CMake/share/cmake-3.12/Modules/FindPackageHandleStandardArgs.cmake:376 (_FPHSA_FAILURE_MESSAGE)
  C:/Program Files (x86)/Microsoft Visual Studio/2017/Community/Common7/IDE/CommonExtensions/Microsoft/CMake/CMake/share/cmake-3.12/Modules/FindPythonInterp.cmake:159 (FIND_PACKAGE_HANDLE_STANDARD_ARGS)
  CMakeLists.txt:22 (find_package)

@TheElementalOfDestruction
Copy link
Author

Also, I don't know why it only finds the cygwin python when visual studio has it's own python installed

@TheElementalOfDestruction
Copy link
Author

Okay, I've managed to manually add:

-DPYTHON_EXECUTABLE="C:\Program Files (x86)\Microsoft Visual Studio\Shared\Python36_64\python.exe"

to the command line arguments and things so far are going well...

@TheElementalOfDestruction
Copy link
Author

Okay, I tried to build and now I get

C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\Common7\IDE\ninja : error : 'external/src/llvm-project-build/Release/lib/LLVMBitWriter.lib', needed by 'src/ar-extractortool/retdec-ar-extractor.exe', missing and no known rule to make it

@TheElementalOfDestruction
Copy link
Author

Oh, the problem is that "external" does not exist. Wtf?

@s3rvac
Copy link
Member

s3rvac commented Apr 25, 2019

RetDec currently does not support the Ninja generator (see #8). On Windows 10 with Visual Studio 2017, we suggest using the following steps, which we know should work (if the retdec/build directory exists, please remove it before proceeding):

  1. Press Windows + r and type cmd.exe.
  2. cd retdec
  3. mkdir build
  4. cd build
  5. cmake .. -DCMAKE_INSTALL_PREFIX=install -G"Visual Studio 15 2017 Win64"
  6. cmake --build . --config Release -- -m
  7. cmake --build . --config Release --target install

If any of the step fails, please let us know which one and attach output from that step.

@TheElementalOfDestruction
Copy link
Author

Visual studios is being stupid and only seeing the python from cygwin. I have to manually add an argument for that.

Everything worked after I ended up having to manually update my flex installation

@PeterMatula
Copy link
Collaborator

Ok, seems like it is working for you now. If not, re-open.

To summarize:

  • If/When we bump minimal required version of CMake to 3.12, we will change PythonInterp to Python.
  • Ninja is not supported at the moment.
  • Make sure the correct CMake version is in the first place in the PATH variable, or manually add an argument as you did.
  • It is the safest to use the recommended build steps.
  • We are working on rewriting the yaramod so that it does not use flex and bison, so hopefully, we will get rid of these deps in some time.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants