matplotlib-cpp icon indicating copy to clipboard operation
matplotlib-cpp copied to clipboard

error: redefinition of 'select_npy_type<long long>'

Open TheInfamousWayne opened this issue 4 years ago • 8 comments

/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 avatar Jun 02 '20 13:06 TheInfamousWayne

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!

TheInfamousWayne avatar Jun 02 '20 13:06 TheInfamousWayne

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)

Cryoris avatar Jun 03 '20 12:06 Cryoris

works for me (macos catalina)

kernbeisser avatar Jun 06 '20 13:06 kernbeisser

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.

Ujjwalkanth avatar Oct 23 '20 12:10 Ujjwalkanth

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

colonelwatch avatar Sep 28 '21 21:09 colonelwatch

@Cryoris Thx, this works for me.

linzhuyue avatar Mar 15 '22 07:03 linzhuyue

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

WildRackoon avatar Jan 16 '23 18:01 WildRackoon

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?

dantamont avatar Dec 03 '23 05:12 dantamont