2014-10-06 34 views
0

我使用autoconf为我的应用创建Makefile,该应用使用gtkmm-3.0configure脚本正常运行并生成makefile。但是makefile文件提出的目标文件库,后:修改使用autoconf创建的makefile

g++ -g -O2 -lgtkmm-3.0 -latkmm-1.6 -lgdkmm-3.0 -lgiomm-2.4 -lpangomm-1.4 -lgtk-3 -lglibmm-2.4 -lcairomm-1.0 -lgdk-3 -latk-1.0 -lgio-2.0 -lpangocairo-1.0 -lgdk_pixbuf-2.0 -lcairo-gobject -lpango-1.0 -lcairo -lsigc-2.0 -lgobject-2.0 -lglib-2.0 -o base base-base.o 

即给予以下错误:

/usr/include/gtkmm-3.0/gtkmm/papersize.h:45: undefined reference to `Glib::ustring::ustring(char const*)' 
/usr/include/gtkmm-3.0/gtkmm/papersize.h:45: undefined reference to `Glib::ustring::~ustring()' 
/usr/include/gtkmm-3.0/gtkmm/papersize.h:46: undefined reference to `Glib::ustring::ustring(char const*)' 
/usr/include/gtkmm-3.0/gtkmm/papersize.h:46: undefined reference to `Glib::ustring::~ustring()' 
/usr/include/gtkmm-3.0/gtkmm/papersize.h:47: undefined reference to `Glib::ustring::ustring(char const*)' 
/usr/include/gtkmm-3.0/gtkmm/papersize.h:47: undefined reference to `Glib::ustring::~ustring()' 
/usr/include/gtkmm-3.0/gtkmm/papersize.h:48: undefined reference to `Glib::ustring::ustring(char const*)' 
/usr/include/gtkmm-3.0/gtkmm/papersize.h:48: undefined reference to `Glib::ustring::~ustring()' 
/usr/include/gtkmm-3.0/gtkmm/papersize.h:49: undefined reference to `Glib::ustring::ustring(char const*)' 
/usr/include/gtkmm-3.0/gtkmm/papersize.h:49: undefined reference to `Glib::ustring::~ustring()' 
/usr/include/gtkmm-3.0/gtkmm/papersize.h:50: undefined reference to `Glib::ustring::ustring(char const*)' 
/usr/include/gtkmm-3.0/gtkmm/papersize.h:50: undefined reference to `Glib::ustring::~ustring()' 
/usr/include/gtkmm-3.0/gtkmm/papersize.h:51: undefined reference to `Glib::ustring::ustring(char const*)' 
/usr/include/gtkmm-3.0/gtkmm/papersize.h:51: undefined reference to `Glib::ustring::~ustring()' 
base-base.o: In function `main': 
/home/shashwat001/Documents/UbuntuApps/gtkmmApps/FirstApp/src/base.cpp:7: undefined reference to `Glib::ustring::ustring(char const*)' 
/home/shashwat001/Documents/UbuntuApps/gtkmmApps/FirstApp/src/base.cpp:7: undefined reference to `Gtk::Application::create(int&, char**&, Glib::ustring const&, Gio::ApplicationFlags)' 
/home/shashwat001/Documents/UbuntuApps/gtkmmApps/FirstApp/src/base.cpp:7: undefined reference to `Glib::ustring::~ustring()' 
/home/shashwat001/Documents/UbuntuApps/gtkmmApps/FirstApp/src/base.cpp:9: undefined reference to `Gtk::Window::Window(Gtk::WindowType)' 
/home/shashwat001/Documents/UbuntuApps/gtkmmApps/FirstApp/src/base.cpp:10: undefined reference to `Gtk::Window::set_default_size(int, int)' 
/home/shashwat001/Documents/UbuntuApps/gtkmmApps/FirstApp/src/base.cpp:12: undefined reference to `Gtk::Application::run(Gtk::Window&)' 
/home/shashwat001/Documents/UbuntuApps/gtkmmApps/FirstApp/src/base.cpp:9: undefined reference to `Gtk::Window::~Window()' 
/home/shashwat001/Documents/UbuntuApps/gtkmmApps/FirstApp/src/base.cpp:13: undefined reference to `Glib::ustring::~ustring()' 
/home/shashwat001/Documents/UbuntuApps/gtkmmApps/FirstApp/src/base.cpp:9: undefined reference to `Gtk::Window::~Window()' 

但是当我手动运行与目标文件上面的语句库之前:

g++ -g -O2 -o base base-base.o -lgtkmm-3.0 -latkmm-1.6 -lgdkmm-3.0 -lgiomm-2.4 -lpangomm-1.4 -lgtk-3 -lglibmm-2.4 -lcairomm-1.0 -lgdk-3 -latk-1.0 -lgio-2.0 -lpangocairo-1.0 -lgdk_pixbuf-2.0 -lcairo-gobject -lpango-1.0 -lcairo -lsigc-2.0 -lgobject-2.0 -lglib-2.0 

然后没有错误发生。 所以问题是库和对象文件的顺序。在autoconf脚本中修改什么以推送Makefile中的订单更改?

+1

我的猜测是你把你的库放到错误的变量中。尽管它们看起来像选项(以'-l'开始),库应该进入'LDLIBS'变量。你可能会把它们放到'LDFLAGS'变量中。 – MadScientist 2014-10-06 22:50:52

+0

你是对的MadScientist。这是问题所在。发布后我很快就明白了,只是忘了更新它。谢谢... – 2014-10-07 01:03:20

回答

0

What to modify in autoconf script to push order change in Makefile?

如果你只使用autoconf的(没有automake的),你需要 修改与 “在” 扩展名,如Makefile.in, 然后重新运行 “的./configure” 文件。

如果您还使用automake而不是Makefile.in,则必须编辑Makefile.am。 然后运行autoreconf & & ./configure