GNOME Bugzilla – Bug 778037
Undefined symbols for architecture x86_64: _gtk_clipboard_get_selection
Last modified: 2017-07-19 14:29:08 UTC
Building gtkmm 3.21.6 or 3.22.x. Getting the following error: Making all in gtk/gtkmm CXXLD libgtkmm-3.0.la clang: warning: argument unused during compilation: '-pthread' Undefined symbols for architecture x86_64: "_gtk_clipboard_get_selection", referenced from: Gtk::Clipboard::get_selection() const in clipboard.o ld: symbol(s) not found for architecture x86_64 clang: error: linker command failed with exit code 1 (use -v to see invocation) make[2]: *** [libgtkmm-3.0.la] Error 1 make[1]: *** [all-recursive] Error 1 make: *** [all] Error 2 This was not an issue for 3.20.1. Building for a min macOSX version 10.9
gtk_clipboard_get_selection() was added in gtk+ 3.21.1. Gtk::Clipboard::get_selection() was added in gtkmm 3.21.2. That explains why it's no problem when building 3.20.1. I don't understand why it's a problem when you build any version of gtkmm. Do you link against a new enough version of gtk+?
Yes, I am linking against gtk+ 3.22.7.
When I build gtk+ and gtkmm with gcc and g++, it does not add a leading underscore to the function names in the .o and .so files. The undefined symbol in your case is _gtk_clipboard_get_selection with a leading underscore. Is it possible that there is a gtk_clipboard_get_selection symbol in the libgtk-3.so file, but gtkmm's clipboard.o file requires _gtk_clipboard_get_selection? I admit that it does not seem probable. If there were this kind of mismatch between the building of gtk+ and the building of gtkmm, I'd expect hundreds of undefined symbols, not just one.
I did an object dump on libgtk-3.dylib and did not see gtk_clipboard_get_selection. Perhaps that is the problem? Here is the result of my object dump: Parthas-MacBook-Pro:gtkmm-3.22.0 partha$ objdump -t ~/local10.9/lib/libgtk-3.dylib |grep -i gtk_clipboard_get 00000000005d2f70 l __DATA,__const _gtk_clipboard_get_type.clipboard_info 00000000005db2b8 l __DATA,__bss _gtk_clipboard_get_type.clipboard_type 0000000000366900 g F __TEXT,__text _gtk_clipboard_get 0000000000367640 g F __TEXT,__text _gtk_clipboard_get_display 0000000000366690 g F __TEXT,__text _gtk_clipboard_get_for_display 0000000000366cf0 g F __TEXT,__text _gtk_clipboard_get_owner 00000000003665b0 g F __TEXT,__text _gtk_clipboard_get_type In case you wish to know the clang version: Parthas-MacBook-Pro:gtkmm-3.22.0 partha$ clang -v Apple LLVM version 8.0.0 (clang-800.0.42.1) Target: x86_64-apple-darwin16.5.0 Thread model: posix InstalledDir: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin I am running Sierra 10.12.4
I would have expected to find both _gtk_clipboard_get_default and _gtk_clipboard_get_selection in the object dump. gtk_clipboard_get_default() has not been wrapped in gtkmm. That explains why it's not reported as a missing symbol. Have you built gtk+ from source? Can you check what's in gtkclipboard.c? gtk_clipboard_get_default() must be declared in gtkclipboard.h, or else your build would fail during compilation instead of linking.
(In reply to Kjell Ahlstedt from comment #5) > gtk_clipboard_get_default() must be declared in gtkclipboard.h, or else your > build would fail during compilation instead of linking. Should be "gtk_clipboard_get_selection() must be ..."
yes, I build from source obtained from http://ftp.gnome.org/pub/GNOME/sources/ I think this maybe the source of the problem. Note that I am building on a Mac. So, you have 2 gtkclipboard files: gtkclipboard.c gtkclipboard-quartz.c. In gtkclipboard.c, you have the correct symbol and you are good: 2222-GdkAtom 2223:gtk_clipboard_get_selection (GtkClipboard *clipboard) 2224-{ 2225- g_return_val_if_fail (GTK_IS_CLIPBOARD (clipboard), GDK_NONE); 2226- 2227- return clipboard->selection; 2228-} In gtkclipboard-quartz.c, you don't have this function and hence the issue.
See gtk+ bug 772281
Gtk+ bug 772281 has been fixed in the gtk-3-22 and master branches. gtk_clipboard_get_selection() is now defined in gtkclipboard-quartz.c. The fix of gtk+ bug 784323 adds a definition of gtk_clipboard_get_default() to gtkclipboard-quartz.c, but that's not important for users of gtkmm. Gtkmm does not wrap gtk_clipboard_get_default(). There's no reason to wrap it. Gtk::Clipboard::get_for_display() with the default value of its second parameter does exactly what Gtk::Clipboard::get_default() would do.