修改使用autoconf创建的makefile

时间:2014-10-06 16:54:14

标签: c++ makefile configure autoconf gtkmm

我正在使用autoconf为使用Makefile的应用创建gtkmm-3.0configure脚本正常运行并生成makefile。但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 个答案:

答案 0 :(得分:0)

  

在autoconf脚本中修改什么以在Makefile中推送订单更改?

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

如果你也使用automake而不是Makefile.in你必须编辑Makefile.am。 然后运行autoreconf&&的./configure