lava / matplotlib-cpp

Extremely simple yet powerful header-only C++ plotting library built on the popular matplotlib
MIT License
4.28k stars 1.12k forks source link

Compilation Error: cannot convert ‘wchar_t**’ to ‘char**’ for argument ‘2’ to ‘void PySys_SetArgv(int, char**)’ #239

Open huuanhhuynguyen opened 3 years ago

huuanhhuynguyen commented 3 years ago

Hello guys,

Compilation error: cannot convert ‘wchar_t**’ to ‘char**’ for argument ‘2’ to ‘void PySys_SetArgv(int, char**)’

Where? /matplotlib-cpp/matplotlibcpp.h:177:57

Workaround Change the line above from PySys_SetArgv(argc, const_cast<wchar_t **>(argv)); to PySys_SetArgv(argc, reinterpret_cast<char **>(const_cast<wchar_t **>(argv))); Then the compilation is done without error.

My Cmake:

include_directories(matplotlib-cpp)
find_package(PythonLibs 2.7)
if(NOT PythonLibs_FOUND)
    message(WARNING "PythonLibs 2.7 not found. Make sure you have installed python 2.7.
       If that doesn't solve the problem, consult
       https://github.com/lava/matplotlib-cpp")
endif()
target_include_directories(my_project PRIVATE ${PYTHON_INCLUDE_DIRS})
target_link_libraries(my_project ${PYTHON_LIBRARIES})

My system: Linux Ubuntu 18.04 Python2.7, mathplotlib, numpy are installed in the correct location. I messaged out the${PYTHON_INCLUDE_DIRS} and ${PYTHON_LIBRARIES}and got:

PYTHON_INCLUDE_DIRS = /usr/include/python2.7
PYTHON_LIBRARIES = /usr/lib/x86_64-linux-gnu/libpython2.7.so

Looks correct to me...

It seems like a python2.7 vs python3.6 issue?

Thank you!

shyney7 commented 3 years ago

There is already a pull request #230 for this. This issue was already opened here #225 . Since there is no reaction from the repo owner yet, the only solution is to use a older commit of the header file or just use python3 instead of python2.