add msvc support and other bugs
This project is most useful, but lacks generality. It seems its optimized for g++ only. I would like to have microsoft visual studio c++ compiler (msvc) support for it as well. Furthermore, I found some different things that might be a bug. My build-system: CMake 3.31.0, c++ 20, MSVC 19.41.34123.0. All references are from commit 4d025b5 of master.
MSVC-Support: I recommend to change common.h line 9 as follows, as visibility is not supported by msvc #ifdef _MSC_VER #define DECL_STRUCT_ATTR #else #define DECL_STRUCT_ATTR attribute((visibility("hidden"))) #endif
CMakeLists.txt line 44 gave an error as it said that the word "optimized" is used - seems to be in ${Python3_LIBRARIES}. I tried to exchanged it with this: target_link_libraries(matplotlibcpp17::matplotlibcpp17 INTERFACE ${Python3_LIBRARIES} pybind11::embed) But then python3XX.lib is not found during linking. I could not find a solution.
Snippet of my CMakeLists.txt for comparison: set(pybind11_DIR "path/to/pybind11") add_subdirectory(ExtLibs/matplotlibcpp17) target_link_libraries(projectname PRIVATE matplotlibcpp17::matplotlibcpp17)
I would highly appreciate if the author(s) of this repo would check their code for compatibility with msvc and check the issues I had.
I printed the variable: message("Python_LIBRARIES:${Python_LIBRARIES}") here is the output Python_LIBRARIES:optimized;C:/Users/[username]/AppData/Local/Programs/Python/Python311/libs/python311.lib;debug;C:/Users/[username]AppData/Local/Programs/Python/Python311/libs/python311_d.lib
so this is where the "optimized"comes from. I guess it should be "release" instead?
If I directly link my project to python3XX.lib, it works: target_link_libraries(projectname PRIVATE "C:/Users/[username]/AppData/Local/Programs/Python/Python311/libs/python311.lib")
but now I have to specify the specific path - not an option when collaborating with others.
Thank you, I will try adding a CI for MSVC so I can check compatibility.
Thank you a lot!
I printed the variable: message("Python_LIBRARIES:${Python_LIBRARIES}") here is the output Python_LIBRARIES:optimized;C:/Users/[username]/AppData/Local/Programs/Python/Python311/libs/python311.lib;debug;C:/Users/[username]AppData/Local/Programs/Python/Python311/libs/python311_d.lib
so this is where the "optimized"comes from. I guess it should be "release" instead?
According to my research, I need the following change to get it to build with cmake on windows, python 3.13 and MSVC: CMakeLists.txt line 49,50,51: Delete this: set_property( TARGET matplotlibcpp17::matplotlibcpp17 PROPERTY INTERFACE_LINK_LIBRARIES ${Python3_LIBRARIES} pybind11::embed) Add this instead: target_link_libraries(matplotlibcpp17::matplotlibcpp17 INTERFACE ${Python3_LIBRARIES} pybind11::embed)
Hey there :) I was just checking if this issue got any updates. Is there anything I can do to resolve this issue in the observable future? ;)