lava / matplotlib-cpp

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

error: redefinition of 'select_npy_type<long long>' #196

Open TheInfamousWayne opened 4 years ago

TheInfamousWayne commented 4 years ago
/Users/vagrawal/new/object_pose/include/matplotlibcpp.hpp:306:20: error: redefinition of 'select_npy_type<long long>'
template <> struct select_npy_type<long long> { const static NPY_TYPES type = NPY_INT64; };
                   ^~~~~~~~~~~~~~~~~~~~~~~~~~
/Users/vagrawal/new/object_pose/include/matplotlibcpp.hpp:297:20: note: previous definition is here
template <> struct select_npy_type<int64_t> { const static NPY_TYPES type = NPY_INT64; };
                   ^
/Users/vagrawal/new/object_pose/include/matplotlibcpp.hpp:307:46: warning: static_assert with no message is a C++17 extension [-Wc++17-extensions]
static_assert(sizeof(unsigned long long) == 8);
                                             ^
                                             , ""
/Users/vagrawal/new/object_pose/include/matplotlibcpp.hpp:308:20: error: redefinition of 'select_npy_type<unsigned long long>'
template <> struct select_npy_type<unsigned long long> { const static NPY_TYPES type = NPY_UINT64; };
                   ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/Users/vagrawal/new/object_pose/include/matplotlibcpp.hpp:301:20: note: previous definition is here
template <> struct select_npy_type<uint64_t> { const static NPY_TYPES type = NPY_UINT64; };
                   ^

I'm using cmake for building. I'm working on macOS Catalina. Do you have suggestions to fix this?

TheInfamousWayne commented 4 years ago

if I comment out those lines and run a simple

plt::plot({1,3,2,4});
plt::show();

I get this error: libc++abi.dylib: terminating with uncaught exception of type std::runtime_error: Error loading module matplotlib.pyplot!

Cryoris commented 4 years ago

You need to uncomment a few lines, as noted in the code here: https://github.com/lava/matplotlib-cpp/blob/60dcd64c8fd4766e5426f57decfb765422a1d3fe/matplotlibcpp.h#L303 (I'm running on Catalina, too)

kernbeisser commented 4 years ago

works for me (macos catalina)

Ujjwalkanth commented 4 years ago

Hello, I had the similar problem, but after commenting out the lines in matplotlibcpp.h. I am getting an error saying

c:/mingw/bin/../lib/gcc/mingw32/6.3.0/../../../../mingw32/bin/ld.exe: cannot find \: No such file or directory collect2.exe: error: ld returned 1 exit status

Any suggestions? Thank you.

colonelwatch commented 3 years ago

Also had this issue in mingw_w64, and commenting out those lines fixed it.

linzhuyue commented 2 years ago

@Cryoris Thx, this works for me.

WildRackoon commented 1 year ago

Those asserts should simply be removed since those (long long and unsigned long long) are type aliases of fixed size types ?

dantamont commented 10 months ago

I'm getting this error with a vcpkg installation of the library with the latest MSVC. Is it possible to update the port so that this no longer occurs?