Linker error for functions expecting const std :: string &

When I try to link to the shared library (gtkmm), I get linker errors for the functions whose signature contains std::string const&.

For example, if a function is declared as

void set_icon_from_file(const std::string&);

g ++ reports

undefined reference to `Gtk::Window::set_icon_from_file(std::string const&)'

I use linker flags from pkg-config, and this does not happen for other functions (for example, functions that take primitive types as arguments), so I suspect the linker is configured correctly.

readelf in my object file gives me

45: 0000000000000000     0 NOTYPE  GLOBAL DEFAULT  UND _ZN3Gtk6Window18set_icon_from_fileERKSs

and in the shared library

10991: 00000000003c0950    96 FUNC    GLOBAL DEFAULT   11 _ZN3Gtk6Window18set_icon_from_fileERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE

, . , , . - __cxx11 ++, ++ 11.

+4
1

++ - filter:

_ZN3Gtk6Window18set_icon_from_fileERKSs
Gtk::Window::set_icon_from_file(std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)
_ZN3Gtk6Window18set_icon_from_fileERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE
Gtk::Window::set_icon_from_file(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)

, glibcxx11 abi. .

, gcc 5.1 .

+3

Source: https://habr.com/ru/post/1624089/


All Articles