error:undefined reference to sth #197
Unanswered
Darkhell101
asked this question in
Q&A
Replies: 1 comment 1 reply
-
You also need to link the library in Linking options: https://gcc.gnu.org/onlinedocs/gcc/Link-Options.html |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I installed binary pkg on ubuntu 21.04 to put into my study.
And I use "g++ -std=c++17 test.cpp -o test" to run a file. Some errors happens. Please help me.
The error is like the following:
/tools$ g++ -std=c++17 test.cpp -o test
/usr/bin/ld: /tmp/ccae4fSO.o: in function
main': test.cpp:(.text+0x289): undefined reference to
matplot::gcf()'/usr/bin/ld: test.cpp:(.text+0x2b2): undefined reference to
matplot::figure_type::width() const' /usr/bin/ld: test.cpp:(.text+0x2be): undefined reference to
matplot::figure_type::width(unsigned int)'/usr/bin/ld: test.cpp:(.text+0x2e2): undefined reference to
matplot::subplot(unsigned long, unsigned long, unsigned long, bool)' /usr/bin/ld: test.cpp:(.text+0x387): undefined reference to
matplot::title(std::basic_string_view<char, std::char_traits >)'/usr/bin/ld: test.cpp:(.text+0x3ab): undefined reference to
matplot::subplot(unsigned long, unsigned long, unsigned long, bool)' /usr/bin/ld: test.cpp:(.text+0x455): undefined reference to
matplot::title(std::basic_string_view<char, std::char_traits >)'/usr/bin/ld: /tmp/ccae4fSO.o: in function
matplot::show()': test.cpp:(.text._ZN7matplot4showEv[_ZN7matplot4showEv]+0x24): undefined reference to
matplot::gcf()'/usr/bin/ld: test.cpp:(.text._ZN7matplot4showEv[_ZN7matplot4showEv]+0x38): undefined reference to
matplot::figure_type::show()' /usr/bin/ld: /tmp/ccae4fSO.o: in function
matplot::save(std::__cxx11::basic_string<char, std::char_traits, std::allocator > const&)':test.cpp:(.text._ZN7matplot4saveERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE[_ZN7matplot4saveERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE]+0x28): undefined reference to
matplot::gcf()' /usr/bin/ld: test.cpp:(.text._ZN7matplot4saveERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE[_ZN7matplot4saveERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE]+0x46): undefined reference to
matplot::figure_type::save(std::__cxx11::basic_string<char, std::char_traits, std::allocator > const&)'/usr/bin/ld: /tmp/ccae4fSO.o: in function
auto matplot::area<std::vector<std::vector<double, std::allocator<double> >, std::allocator<std::vector<double, std::allocator<double> > > >, double>(std::vector<std::vector<double, std::allocator<double> >, std::allocator<std::vector<double, std::allocator<double> > > >, double&&)': test.cpp:(.text._ZN7matplot4areaISt6vectorIS1_IdSaIdEESaIS3_EEJdEEEDaT_DpOT0_[_ZN7matplot4areaISt6vectorIS1_IdSaIdEESaIS3_EEJdEEEDaT_DpOT0_]+0x30): undefined reference to
matplot::gca()'/usr/bin/ld: test.cpp:(.text.ZN7matplot4areaISt6vectorIS1_IdSaIdEESaIS3_EEJdEEEDaT_DpOT0[ZN7matplot4areaISt6vectorIS1_IdSaIdEESaIS3_EEJdEEEDaT_DpOT0]+0x8c): undefined reference to
matplot::axes_type::area(std::vector<std::vector<double, std::allocator<double> >, std::allocator<std::vector<double, std::allocator<double> > > > const&, double, bool, std::basic_string_view<char, std::char_traits<char> >)' /usr/bin/ld: /tmp/ccae4fSO.o: in function
auto matplot::area<std::vector<std::vector<double, std::allocator >, std::allocator<std::vector<double, std::allocator > > >, int, bool>(std::vector<std::vector<double, std::allocator >, std::allocator<std::vector<double, std::allocator > > >, int&&, bool&&)':test.cpp:(.text.ZN7matplot4areaISt6vectorIS1_IdSaIdEESaIS3_EEJibEEEDaT_DpOT0[ZN7matplot4areaISt6vectorIS1_IdSaIdEESaIS3_EEJibEEEDaT_DpOT0]+0x36): undefined reference to
matplot::gca()' /usr/bin/ld: test.cpp:(.text._ZN7matplot4areaISt6vectorIS1_IdSaIdEESaIS3_EEJibEEEDaT_DpOT0_[_ZN7matplot4areaISt6vectorIS1_IdSaIdEESaIS3_EEJibEEEDaT_DpOT0_]+0xad): undefined reference to
matplot::axes_type::area(std::vector<std::vector<double, std::allocator >, std::allocator<std::vector<double, std::allocator > > > const&, double, bool, std::basic_string_view<char, std::char_traits >)'collect2: error: ld returned 1 exit status
Beta Was this translation helpful? Give feedback.
All reactions