Linux上で(私は多くのプロジェクトでやった)オートツールを使って、基本的なQtアプリケーション(Qtの新機能)をコンパイルしようとしています。Qt mocをautotoolsプロジェクト(2017年)で使用するには?
リンクが始まるまで、すべてがうまくコンパイルされているように見えます。
test-mainwindow.o: In function `MainWindow::MainWindow()':
mainwindow.cpp:5: undefined reference to `vtable for MainWindow'
mainwindow.cpp:5: undefined reference to `vtable for MainWindow'
mainwindow.o: In function `MainWindow::~MainWindow()':
mainwindow.cpp:11: undefined reference to `vtable for MainWindow'
mainwindow.cpp:11: undefined reference to `vtable for MainWindow'
mainwindow.o: In function `MainWindow::tr(char const*, char const*, int)':
mainwindow.h:10: undefined reference to `MainWindow::staticMetaObject'
collect2: error: ld returned 1 exit status
make[4]: *** [Makefile:415: test] Error 1
私は前のQtアプリをやっていませんでしたので、私は私のメインウィンドウのヘッダーに多分MOCとは何か、またはQ_OBJECTを疑いますか?私がオンラインで見つけたほとんどすべての例は、4歳以上です。
ソースファイルのMakefile.amは次のようになります。
include $(top_srcdir)/common.am
bin_PROGRAMS = test
test_SOURCES = \
main.cpp \
mainwindow.cpp
test_CPPFLAGS = -I/usr/include -I/usr/local/include -I$(QT5_INCL) -I$(QT5_INCL)/QtWidgets -I$(QT5_INCL)/QtCore
test_LDFLAGS = -L/usr/lib64 -L/usr/local/lib64 -L/usr/local/lib -L$(QT5_LIBS)
test_LDADD = -lrt -lQt5Core -lQt5Gui -lQt5Widgets
そして私は、私はこの時点ではない、完全に正確であると確信しているMakefile.am、...にこれを追加した場合
moc-%.cpp: %.h
/usr/lib64/qt5/bin/moc $(DEFINES) $(INCPATH) $< -o [email protected]
moc-%.cc: %.h
@[email protected] [email protected] $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(MOC_CPPFLAGS) $<
ui-%.h: %.ui
@[email protected] -o [email protected] $<
qrc-%.cc: %.qrc
@[email protected] -o [email protected] $<
Automakeは私も、前にこの/ wの文句を言うでしょう
コンパイルしよう...
Makefile.am:19: warning: '%'-style pattern rules are a GNU make extension
Makefile.am:24: warning: '%'-style pattern rules are a GNU make extension
Makefile.am:27: warning: '%'-style pattern rules are a GNU make extension
Makefile.am:30: warning: '%'-style pattern rules are a GNU make extension
誰もがautotoolsのを使用して、物事のMOC一部を実装する方法についてのアイデアを持っていますか?