Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
2 of 8 tasks
gitzone83 opened this issue Jan 15, 2024 · 0 comments
Open
2 of 8 tasks

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

gitzone83 opened this issue Jan 15, 2024 · 0 comments

Comments

@gitzone83
Copy link

gitzone83 commented Jan 15, 2024

Bug category

  • bug - compilation error
  • bug - compilation warning
  • bug - runtime error
  • bug - runtime warning
  • bug - logic error

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 to matplot::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 to matplot::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

  • cross-platform issue - linux
  • cross-platform issue - windows
  • cross-platform issue - macos

Environment Details:

  • OS: ubuntu 22.04
  • OS Version:
  • Compiler: cmake 3.22
  • Compiler version: gcc/g++ 12

Additional context

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant