修改使用autoconf创建的生成文件

Modify makefile created using autoconf

本文关键字:文件 创建 autoconf 修改      更新时间:2023-10-16

我正在使用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中推送订单更改?

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

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

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