2017-04-09 175 views
0

我想在我的Raspberry Pi 3上编译一个程序。在Raspberry上编译Qt5应用程序

我已经安装了最新的Raspbian并在this manual描述crosscompiled Qt 5.8,然后我试图建立GST到主板上运行它。编译过程似乎完成,但是,我有以下链接错误:

[email protected]:/home/pi/headunit-WIP-headunit-gst/gst# make 
g++ -fPIC -std=c++11 `pkg-config --cflags gstreamer-1.0 gstreamer-app-1.0 gstreamer-video-1.0 libcrypto libusb-1.0 openssl` -I../jni -I/opt/Qt5.8/include/QtWidgets -I/opt/Qt5.8/include -I/opt/Qt5.8/include/QtGui -c main.cc -o main.o 
g++ -o headunit ../jni/hu_aad.o ../jni/hu_aap.o ../jni/hu_ssl.o ../jni/hu_usb.o ../jni/hu_uti.o main.o `pkg-config --libs gstreamer-1.0 gstreamer-app-1.0 gstreamer-video-1.0 libcrypto libusb-1.0 openssl` -L/opt/Qt5.8/include/QtCore/QtCore -L/opt/Qt5.8/include/QtWidgets/QtWidgets -L/opt/Qt5.8/include/QtGui/QtGui 
main.o: In function `gst_loop(gst_app_t*, QApplication*)': 
main.cc:(.text+0xb5c): undefined reference to `QApplication::exec()' 
main.o: In function `main': 
main.cc:(.text+0x10e0): undefined reference to `QApplication::QApplication(int&, char**, int)' 
main.cc:(.text+0x10f0): undefined reference to `qFlagLocation(char const*)' 
main.cc:(.text+0x1104): undefined reference to `qFlagLocation(char const*)' 
main.cc:(.text+0x1134): undefined reference to `QObject::connect(QObject const*, char const*, QObject const*, char const*, Qt::ConnectionType)' 
main.cc:(.text+0x1140): undefined reference to `QMetaObject::Connection::~Connection()' 
main.cc:(.text+0x1178): undefined reference to `QWidget::show()' 
main.cc:(.text+0x11bc): undefined reference to `QWidget::winId() const' 
main.cc:(.text+0x1280): undefined reference to `QWidget::hide()' 
main.cc:(.text+0x12c4): undefined reference to `QApplication::~QApplication()' 
main.cc:(.text+0x12e4): undefined reference to `QApplication::~QApplication()' 
main.o: In function `QWidget::resize(int, int)': 
main.cc:(.text._ZN7QWidget6resizeEii[_ZN7QWidget6resizeEii]+0x38): undefined reference to `QWidget::resize(QSize const&)' 
main.o: In function `HuMainWindow::HuMainWindow()': 
main.cc:(.text._ZN12HuMainWindowC2Ev[_ZN12HuMainWindowC5Ev]+0x38): undefined reference to `QMainWindow::QMainWindow(QWidget*, QFlags<Qt::WindowType>)' 
main.o: In function `HuMainWindow::~HuMainWindow()': 
main.cc:(.text._ZN12HuMainWindowD2Ev[_ZN12HuMainWindowD5Ev]+0x48): undefined reference to `QMainWindow::~QMainWindow()' 
main.o:(.data.rel.ro._ZTV12HuMainWindow[_ZTV12HuMainWindow]+0x8): undefined reference to `QMainWindow::metaObject() const' 
main.o:(.data.rel.ro._ZTV12HuMainWindow[_ZTV12HuMainWindow]+0xc): undefined reference to `QMainWindow::qt_metacast(char const*)' 
main.o:(.data.rel.ro._ZTV12HuMainWindow[_ZTV12HuMainWindow]+0x10): undefined reference to `QMainWindow::qt_metacall(QMetaObject::Call, int, void**)' 
main.o:(.data.rel.ro._ZTV12HuMainWindow[_ZTV12HuMainWindow]+0x1c): undefined reference to `QMainWindow::event(QEvent*)' 
main.o:(.data.rel.ro._ZTV12HuMainWindow[_ZTV12HuMainWindow]+0x20): undefined reference to `QObject::eventFilter(QObject*, QEvent*)' 
main.o:(.data.rel.ro._ZTV12HuMainWindow[_ZTV12HuMainWindow]+0x24): undefined reference to `QObject::timerEvent(QTimerEvent*)' 
main.o:(.data.rel.ro._ZTV12HuMainWindow[_ZTV12HuMainWindow]+0x28): undefined reference to `QObject::childEvent(QChildEvent*)' 
main.o:(.data.rel.ro._ZTV12HuMainWindow[_ZTV12HuMainWindow]+0x2c): undefined reference to `QObject::customEvent(QEvent*)' 
main.o:(.data.rel.ro._ZTV12HuMainWindow[_ZTV12HuMainWindow]+0x30): undefined reference to `QObject::connectNotify(QMetaMethod const&)' 
main.o:(.data.rel.ro._ZTV12HuMainWindow[_ZTV12HuMainWindow]+0x34): undefined reference to `QObject::disconnectNotify(QMetaMethod const&)' 
main.o:(.data.rel.ro._ZTV12HuMainWindow[_ZTV12HuMainWindow]+0x38): undefined reference to `QWidget::devType() const' 
main.o:(.data.rel.ro._ZTV12HuMainWindow[_ZTV12HuMainWindow]+0x3c): undefined reference to `QWidget::setVisible(bool)' 
main.o:(.data.rel.ro._ZTV12HuMainWindow[_ZTV12HuMainWindow]+0x40): undefined reference to `QWidget::sizeHint() const' 
main.o:(.data.rel.ro._ZTV12HuMainWindow[_ZTV12HuMainWindow]+0x44): undefined reference to `QWidget::minimumSizeHint() const' 
main.o:(.data.rel.ro._ZTV12HuMainWindow[_ZTV12HuMainWindow]+0x48): undefined reference to `QWidget::heightForWidth(int) const' 
main.o:(.data.rel.ro._ZTV12HuMainWindow[_ZTV12HuMainWindow]+0x4c): undefined reference to `QWidget::hasHeightForWidth() const' 
main.o:(.data.rel.ro._ZTV12HuMainWindow[_ZTV12HuMainWindow]+0x50): undefined reference to `QWidget::paintEngine() const' 
main.o:(.data.rel.ro._ZTV12HuMainWindow[_ZTV12HuMainWindow]+0x5c): undefined reference to `QWidget::mouseDoubleClickEvent(QMouseEvent*)' 
main.o:(.data.rel.ro._ZTV12HuMainWindow[_ZTV12HuMainWindow]+0x64): undefined reference to `QWidget::wheelEvent(QWheelEvent*)' 
main.o:(.data.rel.ro._ZTV12HuMainWindow[_ZTV12HuMainWindow]+0x68): undefined reference to `QWidget::keyPressEvent(QKeyEvent*)' 
main.o:(.data.rel.ro._ZTV12HuMainWindow[_ZTV12HuMainWindow]+0x6c): undefined reference to `QWidget::keyReleaseEvent(QKeyEvent*)' 
main.o:(.data.rel.ro._ZTV12HuMainWindow[_ZTV12HuMainWindow]+0x70): undefined reference to `QWidget::focusInEvent(QFocusEvent*)' 
main.o:(.data.rel.ro._ZTV12HuMainWindow[_ZTV12HuMainWindow]+0x74): undefined reference to `QWidget::focusOutEvent(QFocusEvent*)' 
main.o:(.data.rel.ro._ZTV12HuMainWindow[_ZTV12HuMainWindow]+0x78): undefined reference to `QWidget::enterEvent(QEvent*)' 
main.o:(.data.rel.ro._ZTV12HuMainWindow[_ZTV12HuMainWindow]+0x7c): undefined reference to `QWidget::leaveEvent(QEvent*)' 
main.o:(.data.rel.ro._ZTV12HuMainWindow[_ZTV12HuMainWindow]+0x80): undefined reference to `QWidget::paintEvent(QPaintEvent*)' 
main.o:(.data.rel.ro._ZTV12HuMainWindow[_ZTV12HuMainWindow]+0x84): undefined reference to `QWidget::moveEvent(QMoveEvent*)' 
main.o:(.data.rel.ro._ZTV12HuMainWindow[_ZTV12HuMainWindow]+0x88): undefined reference to `QWidget::resizeEvent(QResizeEvent*)' 
main.o:(.data.rel.ro._ZTV12HuMainWindow[_ZTV12HuMainWindow]+0x8c): undefined reference to `QWidget::closeEvent(QCloseEvent*)' 
main.o:(.data.rel.ro._ZTV12HuMainWindow[_ZTV12HuMainWindow]+0x90): undefined reference to `QMainWindow::contextMenuEvent(QContextMenuEvent*)' 
main.o:(.data.rel.ro._ZTV12HuMainWindow[_ZTV12HuMainWindow]+0x94): undefined reference to `QWidget::tabletEvent(QTabletEvent*)' 
main.o:(.data.rel.ro._ZTV12HuMainWindow[_ZTV12HuMainWindow]+0x98): undefined reference to `QWidget::actionEvent(QActionEvent*)' 
main.o:(.data.rel.ro._ZTV12HuMainWindow[_ZTV12HuMainWindow]+0x9c): undefined reference to `QWidget::dragEnterEvent(QDragEnterEvent*)' 
main.o:(.data.rel.ro._ZTV12HuMainWindow[_ZTV12HuMainWindow]+0xa0): undefined reference to `QWidget::dragMoveEvent(QDragMoveEvent*)' 
main.o:(.data.rel.ro._ZTV12HuMainWindow[_ZTV12HuMainWindow]+0xa4): undefined reference to `QWidget::dragLeaveEvent(QDragLeaveEvent*)' 
main.o:(.data.rel.ro._ZTV12HuMainWindow[_ZTV12HuMainWindow]+0xa8): undefined reference to `QWidget::dropEvent(QDropEvent*)' 
main.o:(.data.rel.ro._ZTV12HuMainWindow[_ZTV12HuMainWindow]+0xac): undefined reference to `QWidget::showEvent(QShowEvent*)' 
main.o:(.data.rel.ro._ZTV12HuMainWindow[_ZTV12HuMainWindow]+0xb0): undefined reference to `QWidget::hideEvent(QHideEvent*)' 
main.o:(.data.rel.ro._ZTV12HuMainWindow[_ZTV12HuMainWindow]+0xb4): undefined reference to `QWidget::nativeEvent(QByteArray const&, void*, long*)' 
main.o:(.data.rel.ro._ZTV12HuMainWindow[_ZTV12HuMainWindow]+0xb8): undefined reference to `QWidget::changeEvent(QEvent*)' 
main.o:(.data.rel.ro._ZTV12HuMainWindow[_ZTV12HuMainWindow]+0xbc): undefined reference to `QWidget::metric(QPaintDevice::PaintDeviceMetric) const' 
main.o:(.data.rel.ro._ZTV12HuMainWindow[_ZTV12HuMainWindow]+0xc0): undefined reference to `QWidget::initPainter(QPainter*) const' 
main.o:(.data.rel.ro._ZTV12HuMainWindow[_ZTV12HuMainWindow]+0xc4): undefined reference to `QWidget::redirected(QPoint*) const' 
main.o:(.data.rel.ro._ZTV12HuMainWindow[_ZTV12HuMainWindow]+0xc8): undefined reference to `QWidget::sharedPainter() const' 
main.o:(.data.rel.ro._ZTV12HuMainWindow[_ZTV12HuMainWindow]+0xcc): undefined reference to `QWidget::inputMethodEvent(QInputMethodEvent*)' 
main.o:(.data.rel.ro._ZTV12HuMainWindow[_ZTV12HuMainWindow]+0xd0): undefined reference to `QWidget::inputMethodQuery(Qt::InputMethodQuery) const' 
main.o:(.data.rel.ro._ZTV12HuMainWindow[_ZTV12HuMainWindow]+0xd4): undefined reference to `QWidget::focusNextPrevChild(bool)' 
main.o:(.data.rel.ro._ZTV12HuMainWindow[_ZTV12HuMainWindow]+0xd8): undefined reference to `QMainWindow::createPopupMenu()' 
main.o:(.data.rel.ro._ZTV12HuMainWindow[_ZTV12HuMainWindow]+0xec): undefined reference to `non-virtual thunk to QWidget::devType() const' 
main.o:(.data.rel.ro._ZTV12HuMainWindow[_ZTV12HuMainWindow]+0xf0): undefined reference to `non-virtual thunk to QWidget::paintEngine() const' 
main.o:(.data.rel.ro._ZTV12HuMainWindow[_ZTV12HuMainWindow]+0xf4): undefined reference to `non-virtual thunk to QWidget::metric(QPaintDevice::PaintDeviceMetric) const' 
main.o:(.data.rel.ro._ZTV12HuMainWindow[_ZTV12HuMainWindow]+0xf8): undefined reference to `non-virtual thunk to QWidget::initPainter(QPainter*) const' 
main.o:(.data.rel.ro._ZTV12HuMainWindow[_ZTV12HuMainWindow]+0xfc): undefined reference to `non-virtual thunk to QWidget::redirected(QPoint*) const' 
main.o:(.data.rel.ro._ZTV12HuMainWindow[_ZTV12HuMainWindow]+0x100): undefined reference to `non-virtual thunk to QWidget::sharedPainter() const' 
main.o:(.data.rel.ro._ZTI12HuMainWindow[_ZTI12HuMainWindow]+0x8): undefined reference to `typeinfo for QMainWindow' 
collect2: error: ld returned 1 exit status 
Makefile:23: recipe for target 'headunit' failed 
make: *** [headunit] Error 1 

据我了解,有一个QApplication没有提及,但我写的Makefile

CC=gcc 
CPP=g++ 
LD=ld 
INCLUDES=`pkg-config --cflags gstreamer-1.0 gstreamer-app-1.0 gstreamer-video-1.0 libcrypto libusb-1.0 openssl` -I$(TOP)/jni -I/opt/Qt5.8/include/QtWidgets -I/opt/Qt5.8/include -I/opt/Qt5.8/include/QtGui 
CFLAGS= 
CPPFLAGS=-fPIC -std=c++11 
LFLAGS=`pkg-config --libs gstreamer-1.0 gstreamer-app-1.0 gstreamer-video-1.0 libcrypto libusb-1.0 openssl` -L/opt/Qt5.8/include/QtCore/QtCore -L/opt/Qt5.8/include/QtWidgets/QtWidgets -L/opt/Qt5.8/include/QtGui/QtGui 
TOP = .. 
AASRCS = $(TOP)/jni/hu_aad.c \ 
     $(TOP)/jni/hu_aap.c \ 
      $(TOP)/jni/hu_ssl.c \ 
     $(TOP)/jni/hu_usb.c \ 
     $(TOP)/jni/hu_uti.c 
HSRCS =  main.cc 
OBJS = $(AASRCS:.c=.o) $(HSRCS:.cc=.o) 
APP = headunit 

.PHONY: depend clean 

all: $(APP) 

$(APP): $(OBJS) 
    $(CPP) -o $(APP) $(OBJS) $(LFLAGS) 

.c.o: 
    $(CC) $(CFLAGS) $(INCLUDES) -c $< -o [email protected] 

.cc.o: 
    $(CPP) $(CPPFLAGS) $(INCLUDES) -c $< -o [email protected] 

clean: 
    rm -f $(OBJS) *~ $(APP) 

depend: $(SRCS) 
    makedepend $^ 

# DO NOT DELETE 

我也试过qmake -project来获得一个项目文件,然后qmake和make。 但后来我收到其他错误。

也许有人可以帮助我解决这些问题,最终编译这个程序。

回答

0

您是否试图让Pi通过将lt.so.conf中的Qt安装的/ lib文件夹添加来找到这些库? 在你的情况下,这可能看起来像echo /opt/Qt5.8/lib | sudo tee /etc/ld.so.conf.d/qt5pi.conf

之后,你必须使用sudo ldconfig

现在链接可以找到Qt的利布斯没有任何补充,你的Makefile重新加载ld.so.conf中。 也许这会帮助你。

相关问题