Closed andreadimax closed 1 year ago
There are no instructions to build it with MSYS2 in https://alandefreitas.github.io/matplotplusplus/integration/install/build-from-source/build-and-install/
Maybe you need something like
cmake .. -D CMAKE_BUILD_TYPE=Release -D CMAKE_CXX_FLAGS="-O2" -D CMAKE_C_COMPILER=/path/to/mingw -D CMAKE_CXX_COMPILER=/path/to/mingw
I have built with the following command:
cmake .. -G "MinGW Makefiles" -DCMAKE_BUILD_TYPE=Release -D CMAKE_CXX_FLAGS="-O2" -D CMAKE_C_COMPILER=P:/ath/to/gcc.exe -D CMAKE_CXX_COMPILER=P:/ath/to/g++.exe -D CMAKE_MAKE_PROGRAM=P:/ath/to/make.exe -DBUILD_EXAMPLES=OFF -DBUILD_TESTS=OFF
and build process went correctly. MinGW compilers were recognized correctly. The problem is not in building but during linking
@alandefreitas I have repeated the same operations with the version 11.2.0 of MinGW g++ compiler and it all works fine. I have executed the same previous command (except for specifying CMAKE variable to that version of compiler) and then built. So I think the problem it is just the 12.2.0 version.
Steps to reproduce:
If you build with the command in my previous comment (with version 12.2.0) of compiler and then execute:
cmake --build . --parallel 8 --config Release
build process is ok until 100% and then you obtain a tons of underfined reference.
NOTE: c++ standard I specified is 17
A little extract:
[ 86%] Building CXX object matplotplusplus/source/matplot/CMakeFiles/matplot.dir/axes_objects/surface.cpp.obj
[ 88%] Building CXX object matplotplusplus/source/matplot/CMakeFiles/matplot.dir/freestanding/axes_functions.cpp.obj
[ 91%] Building CXX object matplotplusplus/source/matplot/CMakeFiles/matplot.dir/axes_objects/vectors.cpp.obj
[ 93%] Building CXX object matplotplusplus/source/matplot/CMakeFiles/matplot.dir/freestanding/histcounts.cpp.obj
[ 95%] Linking CXX static library libmatplot.a
[ 95%] Built target matplot
[ 97%] Building CXX object CMakeFiles/prova_matplot.dir/prova_matplot.cpp.obj
[100%] Linking CXX executable prova_matplot.exe
D:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/12.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: CMakeFiles\prova_matplot.dir/objects.a(prova_matplot.cpp.obj):prova_matplot.:(.text+0xd8): undefined reference to `std::ios_base::Init::~Init()'
D:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/12.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: CMakeFiles\prova_matplot.dir/objects.a(prova_matplot.cpp.obj):prova_matplot.:(.xdata$_ZN7matplot4plotISt6vectorIdSaIdEEJS3_RA5_KcEEEDaT_DpOT0_+0x10): undefined reference to `__gxx_personality_seh0'
D:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/12.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: CMakeFiles\prova_matplot.dir/objects.a(prova_matplot.cpp.obj):prova_matplot.:(.text$_ZNSt6vectorIdSaIdEEC1ERKS1_[_ZNSt6vectorIdSaIdEEC1ERKS1_]+0x38): undefined reference to `operator new(unsigned long long)'
D:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/12.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: CMakeFiles\prova_matplot.dir/objects.a(prova_matplot.cpp.obj):prova_matplot.:(.text$_ZNSt6vectorIdSaIdEEC1ERKS1_[_ZNSt6vectorIdSaIdEEC1ERKS1_]+0x89): undefined reference to `std::__throw_bad_array_new_length()'
D:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/12.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: CMakeFiles\prova_matplot.dir/objects.a(prova_matplot.cpp.obj):prova_matplot.:(.rdata+0x10): undefined reference to `vtable for __cxxabiv1::__class_type_info'
D:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/12.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: CMakeFiles\prova_matplot.dir/objects.a(prova_matplot.cpp.obj):prova_matplot.:(.rdata+0x30): undefined reference to `vtable for __cxxabiv1::__class_type_info'
D:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/12.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: CMakeFiles\prova_matplot.dir/objects.a(prova_matplot.cpp.obj):prova_matplot.:(.rdata+0x50): undefined reference to `vtable for __cxxabiv1::__class_type_info'
D:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/12.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: CMakeFiles\prova_matplot.dir/objects.a(prova_matplot.cpp.obj):prova_matplot.:(.text.startup+0x157): undefined reference to `operator delete(void*, unsigned long long)'
D:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/12.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: CMakeFiles\prova_matplot.dir/objects.a(prova_matplot.cpp.obj):prova_matplot.:(.text.startup+0x1fc): undefined reference to `operator delete(void*, unsigned long long)'
D:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/12.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: CMakeFiles\prova_matplot.dir/objects.a(prova_matplot.cpp.obj):prova_matplot.:(.text.startup+0x219): undefined reference to `operator delete(void*, unsigned long long)'
D:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/12.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: CMakeFiles\prova_matplot.dir/objects.a(prova_matplot.cpp.obj):prova_matplot.:(.text.startup+0x2ca): undefined reference to `operator delete(void*, unsigned long long)'
D:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/12.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: CMakeFiles\prova_matplot.dir/objects.a(prova_matplot.cpp.obj):prova_matplot.:(.text.startup+0x2e7): undefined reference to `operator delete(void*, unsigned long long)'
D:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/12.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: CMakeFiles\prova_matplot.dir/objects.a(prova_matplot.cpp.obj):prova_matplot.:(.text.startup+0x363): undefined reference to `operator new(unsigned long long)'
D:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/12.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: CMakeFiles\prova_matplot.dir/objects.a(prova_matplot.cpp.obj):prova_matplot.:(.text.startup+0x442): undefined reference to `operator delete(void*, unsigned long long)'
D:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/12.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: CMakeFiles\prova_matplot.dir/objects.a(prova_matplot.cpp.obj):prova_matplot.:(.text.startup+0x4a6): undefined reference to `operator delete(void*, unsigned long long)'
D:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/12.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: CMakeFiles\prova_matplot.dir/objects.a(prova_matplot.cpp.obj):prova_matplot.:(.text.startup+0x4bd): undefined reference to `operator delete(void*, unsigned long long)'
D:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/12.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: CMakeFiles\prova_matplot.dir/objects.a(prova_matplot.cpp.obj):prova_matplot.:(.text.startup+0x603): undefined reference to `operator delete(void*, unsigned long long)'
D:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/12.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: CMakeFiles\prova_matplot.dir/objects.a(prova_matplot.cpp.obj):prova_matplot.:(.text.startup+0x61a): undefined reference to `operator delete(void*, unsigned long long)'
Hope this can help. Let me know if I have to consider issue closed
Great. I'm glad it worked.
Bug category
Describe the bug I have installed building from source succesfully Matplot++ through the guide at this link: https://alandefreitas.github.io/matplotplusplus/integration/install/build-from-source/build-and-install/ and I have checked all the dependencies. When I try to compile a simple example program with g++ I receive many linking errors and I don't understand how to solve. I read other related issues like #260 but I am not able to solve the same. I'd like to continue using g++. Can you help me?
Steps to Reproduce Trying to compile the following code:
with the following command:
g++ -I 'D:\Matplot++\include' -L 'D:\Matplot++\lib' -lmatplot -std=c++20 -g prova_matplot.cpp -o matplot
D:\Matplot++\ is the target folder for cmake install
Output This is the output:
Platform
Environment Details: