cross compilation from ubuntu to Raspberry Pi error: undefined symbol

2

i'm running Qt Creator 3.0.1 (Based on Qt 5.2.1 (GCC 4.8.2, 64 bit)) on Ubuntu 14.4 64bit on VirtualBox on Windows 7 64bit I'm trying to cross compile to Raspberry Pi and run very simple program:

MainWindow.h:

#ifndef MAINWINDOW_H
#define MAINWINDOW_H

#include <QMainWindow>

namespace Ui {
    class MainWindow;
}

class MainWindow : public QMainWindow
{
    Q_OBJECT

public:
    explicit MainWindow(QWidget *parent = 0);
    ~MainWindow();

protected slots:
    void ButtonClicked();

private:
    Ui::MainWindow *ui;
};

#endif // MAINWINDOW_H

LinuxProject4.cpp:

#include "MainWindow.h"
#include <QApplication>

int main(int argc, char *argv[])
{
    QApplication a(argc, argv);
    MainWindow w;
    w.show();
    return a.exec();
}

MainWindow.cpp:

#include "MainWindow.h"
#include "ui_MainWindow.h"
#include <QMessageBox>

MainWindow::MainWindow(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::MainWindow)
{
    ui->setupUi(this);
}

MainWindow::~MainWindow()
{
    delete ui;
}

void MainWindow::ButtonClicked()
{
    QMessageBox msgBox;
    msgBox.setText("Hello, World!");
    msgBox.setWindowTitle("VisualGDB Qt Demo");
    msgBox.exec();
}

MainWindow.ui:

<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>MainWindow</class>
<widget class="QMainWindow" name="MainWindow">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>400</width>
<height>300</height>
</rect>
</property>
<property name="windowTitle">
<string>LinuxProject4</string>
</property>
<widget class="QWidget" name="centralWidget">
<widget class="QPushButton" name="pushButton">
<property name="geometry">
<rect>
<x>160</x>
<y>120</y>
<width>75</width>
<height>23</height>
</rect>
</property>
<property name="text">
<string>Press me</string>
</property>
</widget>
</widget>
<widget class="QMenuBar" name="menuBar">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>400</width>
<height>25</height>
</rect>
</property>
</widget>
<widget class="QToolBar" name="mainToolBar">
<attribute name="toolBarArea">
<enum>TopToolBarArea</enum>
</attribute>
<attribute name="toolBarBreak">
<bool>false</bool>
</attribute>
</widget>
<widget class="QStatusBar" name="statusBar"/>
</widget>
<layoutdefault spacing="6" margin="11"/>
<resources/>
<connections>
<connection>
<sender>pushButton</sender>
<signal>clicked()</signal>
<receiver>MainWindow</receiver>
<slot>ButtonClicked()</slot>
<hints>
<hint type="sourcelabel">
<x>199</x>
<y>89</y>
</hint>
<hint type="destinationlabel">
<x>279</x>
<y>230</y>
</hint>
</hints>
</connection>
</connections>
<slots>
<slot>ButtonClicked()</slot>
</slots>
</ui>

OrianFirstTest.pro:

#-------------------------------------------------
Project created by QtCreator 2015-04-20T19:02:59
#-------------------------------------------------

QT += core gui

greaterThan(QT_MAJOR_VERSION, 4): QT += widgets

TARGET = OrianFirstTest
target.files = OrianFirstTest
target.path = /home/pi
INSTALLS = target
CONFIG += console
CONFIG -= app_bundle

TEMPLATE = app

SOURCES += 
MainWindow.cpp 
LinuxProject4.cpp

FORMS += 
MainWindow.ui

HEADERS += 
MainWindow.h

Running qmake is fine and building it as well. When I try to run it I see for a split second the GUI and I get this message on my PC:

/home/pi/OrianFirstTest: symbol lookup error: /home/pi/OrianFirstTest: undefined symbol: _ZN7QWidget8qwsEventEP8QWSEvent Application finished with exit code 127.

running on Raspberry Pi: "ldd OrianFirstTest" returns: "not a dynamic executable".

Running on Raspberry Pi: "echo _ZN7QWidget8qwsEventEP8QWSEvent | c++filt" returns: "QWidget::qwsEvent(QWSEvent*)".

Running on Raspberry Pi: "readelf -d OrianFirstTest" return:

Dynamic section at offset 0x400c contains 32 entries:

Tag Type Name/Value

0x000000 01 (NEEDED) Shared library: [libQtGui.so.4]

0x00000001 (NEEDED) Shared library: [libQtNetwork.so.4]

0x00000001 (NEEDED) Shared library: [libQtCore.so.4]

0x00000001 (NEEDED) Shared library: [libpthread.so.0]

0x00000001 (NEEDED) Shared library: [libstdc++.so.6]

0x00000001 (NEEDED) Shared library: [libm.so.6]

0x00000001 (NEEDED) Shared library: [libgcc_s.so.1]

0x00000001 (NEEDED) Shared library: [libc.so.6]

0x0000000f (RPATH) Library rpath: [/opt/qt/lib]

0x0000000c (INIT) 0x9f64

0x0000000d (FINI) 0xb74c

0x00000019 (INIT_ARRAY) 0x14000

0x0000001b (INIT_ARRAYSZ) 4 (bytes)

0x0000001a (FINI_ARRAY) 0x14004

0x0000001c (FINI_ARRAYSZ) 4 (bytes)

0x00000004 (HASH) 0x8168

0x00000005 (STRTAB) 0x8c04

0x00000006 (SYMTAB) 0x84c4

0x0000000a (STRSZ) 3806 (bytes)

0x0000000b (SYMENT) 16 (bytes)

0x00000015 (DEBUG) 0x0

0x00000003 (PLTGOT) 0x14134

0x00000002 (PLTRELSZ) 776 (bytes)

0x00000014 (PLTREL) REL

0x00000017 (JMPREL) 0x9c5c

0x00000011 (REL) 0x9c3c

0x00000012 (RELSZ) 32 (bytes)

0x00000013 (RELENT) 8 (bytes)

0x6ffffffe (VERNEED) 0x9bcc

0x6fffffff (VERNEEDNUM) 3

0x6ffffff0 (VERSYM) 0x9ae2

0x00000000 (NULL) 0x0

Please help me and guide me to fix it. Thanks a lot, Orian.

c++
qt
raspberry-pi
cross-platform
cross-compiling
asked on Stack Overflow May 12, 2015 by Orian Zinger • edited Jun 20, 2020 by Community

0 Answers

Nobody has answered this question yet.


User contributions licensed under CC BY-SA 3.0