alandefreitas / matplotplusplus

Matplot++: A C++ Graphics Library for Data Visualization šŸ“ŠšŸ—¾
https://alandefreitas.github.io/matplotplusplus/
MIT License
4.1k stars 311 forks source link

undefined reference to `matplot::gca()' #388

Open gitzone83 opened 5 months ago

gitzone83 commented 5 months ago

Bug category

Describe the bug

I installed matplotplusplus using the following instructions from the official guide

mkdir build cd build cmake .. -DCMAKE_BUILD_TYPE=Release -DCMAKE_CXX_FLAGS="-O2" -DMATPLOTPP_BUILD_EXAMPLES=OFF -DMATPLOTPP_BUILD_TESTS=OFF sudo cmake --build . --parallel 2 --config Release sudo cmake --install .

on Ubuntu 22.04 system with g++ 12 and cmake 3.22 under Eclipse 2023-12 IDE

Steps to Reproduce

just create a new cmake project with defaults, create a simple default project with the following code

include

include <matplot/matplot.h>

include

include

int main(int argc, char **argv) {

std::cout << "Hello World" << std::endl;

std::vector<int> y = {2, 4, 7, 7, 6, 3, 9, 7, 3, 5};
matplot::plot(y);

return 0;

}

and build it.

Output

Building in: /home/user/workspace-cpp/Project-Cmake/build/default cmake --build . --target all [ 50%] Linking CXX executable Project-Cmake /usr/bin/ld: CMakeFiles/Project-Cmake.dir/Project-Cmake.cpp.o: in function auto matplot::plot<std::vector<int, std::allocator<int> >>(std::vector<int, std::allocator<int> >)': Project-Cmake.cpp:(.text._ZN7matplot4plotISt6vectorIiSaIiEEJEEEDaT_DpOT0_[_ZN7matplot4plotISt6vectorIiSaIiEEJEEEDaT_DpOT0_]+0x2c): undefined reference tomatplot::gca()' /usr/bin/ld: CMakeFiles/Project-Cmake.dir/Project-Cmake.cpp.o: in function std::shared_ptr<matplot::line> matplot::axes_type::plot<std::vector<int, std::allocator<int> > >(std::vector<int, std::allocator<int> > const&, std::basic_string_view<char, std::char_traits<char> >)': Project-Cmake.cpp:(.text._ZN7matplot9axes_type4plotISt6vectorIiSaIiEEEESt10shared_ptrINS_4lineEERKT_St17basic_string_viewIcSt11char_traitsIcEE[_ZN7matplot9axes_type4plotISt6vectorIiSaIiEEEESt10shared_ptrINS_4lineEERKT_St17basic_string_viewIcSt11char_traitsIcEE]+0x67): undefined reference tomatplot::axes_type::plot(std::vector<double, std::allocator > const&, std::basic_string_view<char, std::char_traits >)' collect2: error: ld returned 1 exit status gmake[2]: [CMakeFiles/Project-Cmake.dir/build.make:97: Project-Cmake] Error 1 gmake[1]: [CMakeFiles/Makefile2:83: CMakeFiles/Project-Cmake.dir/all] Error 2 gmake: *** [Makefile:91: all] Error 2 Build complete (5 errors, 0 warnings): /home/user/workspace-cpp/Project-Cmake/build/default

Platform

Environment Details:

Additional context