diff --git a/contrib/CMakeLists.txt b/contrib/CMakeLists.txt index ba14b86..56d88d6 100644 --- a/contrib/CMakeLists.txt +++ b/contrib/CMakeLists.txt @@ -5,9 +5,11 @@ set(CMAKE_CXX_STANDARD 11) set(CMAKE_CXX_STANDARD_REQUIRED ON) include_directories(${PYTHONHOME}/include) +include_directories(${PYTHONHOME}/Lib/site-packages/numpy/core/include) link_directories(${PYTHONHOME}/libs) -add_definitions(-DMATPLOTLIBCPP_PYTHON_HEADER=Python.h) +# add_definitions(-DMATPLOTLIBCPP_PYTHON_HEADER=Python.h) +# add_definitions(-DWITHOUT_NUMPY) # message(STATUS "*** dump start cmake variables ***") # get_cmake_property(_variableNames VARIABLES) @@ -19,3 +21,4 @@ add_definitions(-DMATPLOTLIBCPP_PYTHON_HEADER=Python.h) add_executable(minimal ${CMAKE_CURRENT_SOURCE_DIR}/../examples/minimal.cpp) add_executable(basic ${CMAKE_CURRENT_SOURCE_DIR}/../examples/basic.cpp) add_executable(modern ${CMAKE_CURRENT_SOURCE_DIR}/../examples/modern.cpp) +add_executable(animation ${CMAKE_CURRENT_SOURCE_DIR}/../examples/animation.cpp) diff --git a/contrib/README.md b/contrib/README.md index efc0a50..09480cb 100644 --- a/contrib/README.md +++ b/contrib/README.md @@ -8,12 +8,29 @@ contributors are not required to and may be unable to check whether their changes break any of them. ## Windows support +Tested on the following environment +* Windows 10 - 64bit +* Anaconda 4.3 (64 bit) +* Python 3.6.0 +* CMake 3.9.4 +* Visual Studio 2017, 2015, 2013 + +### Visual Studio 2017 +Set Environment Variable VS150COMNTOOLS to [yourInstallPath]\Common7\Tools +e.g. C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\Common7\Tools\ ### Configuring and Building Samples +1. Edit WinBuild.cmd for your environment(Line:4-6) + if NOT DEFINED MSVC_VERSION set MSVC_VERSION=[Your Visual Studio Version(12, 14, 15)] + if NOT DEFINED CMAKE_CONFIG set CMAKE_CONFIG=Release + if NOT DEFINED PYTHONHOME set PYTHONHOME=[Your Python Path] +2. Run WinBuild.cmd to build ```cmd > cd contrib > WinBuild.cmd ``` - The `WinBuild.cmd` will set up temporal ENV variables and build binaries in (matplotlib root)/examples with the Release configuration. + +3. Find exe files in examples/build/Release +Note: platforms folder is important to make qt works. diff --git a/contrib/WinBuild.cmd b/contrib/WinBuild.cmd index 4e3b450..7bd26f8 100644 --- a/contrib/WinBuild.cmd +++ b/contrib/WinBuild.cmd @@ -1,7 +1,7 @@ @echo off @setlocal EnableDelayedExpansion -if NOT DEFINED MSVC_VERSION set MSVC_VERSION=14 +if NOT DEFINED MSVC_VERSION set MSVC_VERSION=15 if NOT DEFINED CMAKE_CONFIG set CMAKE_CONFIG=Release if NOT DEFINED PYTHONHOME set PYTHONHOME=C:/Users/%username%/Anaconda3 @@ -14,13 +14,21 @@ if "%MSVC_VERSION%"=="14" ( ) else if "%MSVC_VERSION%"=="12" ( if "%processor_architecture%" == "AMD64" ( set CMAKE_GENERATOR=Visual Studio 12 2013 Win64 - ) else ( set CMAKE_GENERATOR=Visual Studio 12 2013 ) +) else if "%MSVC_VERSION%"=="15" ( + if "%processor_architecture%" == "AMD64" ( + set CMAKE_GENERATOR=Visual Studio 15 2017 Win64 + ) else ( + set CMAKE_GENERATOR=Visual Studio 15 2017 + ) +) +if "%MSVC_VERSION%"=="15" ( + set batch_file=!VS%MSVC_VERSION%0COMNTOOLS!..\..\VC\Auxiliary\Build\vcvarsall.bat +) else ( + set batch_file=!VS%MSVC_VERSION%0COMNTOOLS!..\..\VC\vcvarsall.bat ) - -set batch_file=!VS%MSVC_VERSION%0COMNTOOLS!..\..\VC\vcvarsall.bat call "%batch_file%" %processor_architecture% pushd .. diff --git a/matplotlibcpp.h b/matplotlibcpp.h index 638a272..bdee30e 100644 --- a/matplotlibcpp.h +++ b/matplotlibcpp.h @@ -68,6 +68,14 @@ namespace matplotlibcpp { } private: +#if PY_MAJOR_VERSION >= 3 + int init_numpy(){ +#else + void init_numpy(){ +#endif + import_array() + } + _interpreter() { // optional but recommended @@ -80,7 +88,7 @@ namespace matplotlibcpp { Py_Initialize(); #ifndef WITHOUT_NUMPY - import_array(); // initialize numpy C-API + init_numpy(); // initialize numpy C-API #endif PyObject* matplotlibname = PyString_FromString("matplotlib");