GNOME Bugzilla – Bug 568416
undefined reference to Gtk::Stock::ORIENTATION_*
Last modified: 2009-01-20 16:40:38 UTC
Got linking error when compiling the following program: #include <gtkmm.h> int main(int argc, char* argv[]) { Gtk::Main kit(argc, argv); // test gtk stock new Gtk::Button(Gtk::Stock::ORIENTATION_PORTRAIT); new Gtk::Button(Gtk::Stock::ORIENTATION_LANDSCAPE); new Gtk::Button(Gtk::Stock::ORIENTATION_REVERSE_PORTRAIT); new Gtk::Button(Gtk::Stock::ORIENTATION_REVERSE_LANDSCAPE); return 0; } and receive the following error under Ubuntu: tao@vm-ubuntu:~/temp$ pkg-config --modversion gtkmm-2.4 2.14.1 tao@vm-ubuntu:~/temp$ g++ test_stock.cpp -o test_stock `pkg-config gtkmm-2.4 --cflags --libs` /tmp/ccifPF87.o: In function `main': test_stock.cpp:(.text+0x1c7): undefined reference to `Gtk::Stock::ORIENTATION_PORTRAIT' test_stock.cpp:(.text+0x25b): undefined reference to `Gtk::Stock::ORIENTATION_LANDSCAPE' test_stock.cpp:(.text+0x2ef): undefined reference to `Gtk::Stock::ORIENTATION_REVERSE_PORTRAIT' test_stock.cpp:(.text+0x383): undefined reference to `Gtk::Stock::ORIENTATION_REVERSE_LANDSCAPE' The error also happened under Windows version, which got the following linking error: 1>Linking... 1>main.obj : error LNK2001: unresolved external symbol "__declspec(dllimport) struct Gtk::BuiltinStockID const Gtk::Stock::ORIENTATION_REVERSE_PORTRAIT" (__imp_?ORIENTATION_REVERSE_PORTRAIT@Stock@Gtk@@3UBuiltinStockID@2@B) 1>main.obj : error LNK2001: unresolved external symbol "__declspec(dllimport) struct Gtk::BuiltinStockID const Gtk::Stock::ORIENTATION_REVERSE_LANDSCAPE" (__imp_?ORIENTATION_REVERSE_LANDSCAPE@Stock@Gtk@@3UBuiltinStockID@2@B) 1>main.obj : error LNK2001: unresolved external symbol "__declspec(dllimport) struct Gtk::BuiltinStockID const Gtk::Stock::ORIENTATION_LANDSCAPE" (__imp_?ORIENTATION_LANDSCAPE@Stock@Gtk@@3UBuiltinStockID@2@B) 1>main.obj : error LNK2001: unresolved external symbol "__declspec(dllimport) struct Gtk::BuiltinStockID const Gtk::Stock::ORIENTATION_PORTRAIT" (__imp_?ORIENTATION_PORTRAIT@Stock@Gtk@@3UBuiltinStockID@2@B) 1>C:\Users\Tao\Documents\Visual Studio 2008\Projects\gtkmm\Debug\gtkmm_minidemo.exe : fatal error LNK1120: 4 unresolved externals I tested all Gtk::Stock::*, and only the ORIENTATION_* got this linking errors.
Created attachment 126832 [details] [review] proposed patch The bug may caused by missing assignments in gtk/gtkmm/stock.cc. The proposed patch contains the missing assignments.
Good catch. Fixed with this commit in svn trunk and the gtkmm-2-14 branch: 2009-01-20 Murray Cumming <murrayc@murrayc.com> * gtk/gtkmm/stock.cc: Actually define and initialize ORIENTATION_PORTRAIT, ORIENTATION_LANDSCAPE, ORIENTATION_REVERSE_LANDSCAPE, and ORIENTATION_REVERSE_PORTRAIT, avoiding undefined reference errors when trying to use these. Bug #568416 (Tao Wang).