【问题标题】:Modify makefile created using autoconf修改使用 autoconf 创建的 makefile
【发布时间】:2014-10-06 16:54:13
【问题描述】:

我正在使用autoconf 为使用gtkmm-3.0 的应用创建Makefileconfigure 脚本运行正常并生成了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中的订单更改?

【问题讨论】:

  • 我的猜测是您将库放入错误的变量中。即使它们看起来像选项(以-l 开头),库也应该进入LDLIBS 变量。您可能会将它们放入 LDFLAGS 变量中。
  • 你是对的疯狂科学家。这就是问题所在。发帖后很快就知道了,只是忘记更新了。谢谢...

标签: c++ makefile configure autoconf gtkmm


【解决方案1】:

在 autoconf 脚本中修改什么来推动 Makefile 中的顺序变化?

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

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

【讨论】:

    猜你喜欢
    • 2012-06-28
    • 2013-06-23
    • 1970-01-01
    • 2012-12-20
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多