Results 1 to 2 of 2

Thread: failed to crosscompiling with qt 4.8

  1. #1
    Join Date
    Jan 2016
    Posts
    1
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11

    Default failed to crosscompiling with qt 4.8

    Hi,
    when i am trying to crosscompile my qt application below errors are commig
    i am using qt 4.8 and ubuntu 12.4


    :
    root@anvesh-virtual-machine:~/Desktop/new_test# make
    arm-linux-gnueabihf-g++ -O0 -g -Wall -I./ -I/root/rpi/mntrpi/usr/include/qt4/ -I/root/rpi/mntrpi/usr/include/qt4/QtGui -I/root/rpi/mntrpi/usr/include/qt4/Qt -I/root/rpi/mntrpi/usr/include/qt4/QtCore -c main.cpp
    arm-linux-gnueabihf-g++ -O0 -g -Wall -I./ -I/root/rpi/mntrpi/usr/include/qt4/ -I/root/rpi/mntrpi/usr/include/qt4/QtGui -I/root/rpi/mntrpi/usr/include/qt4/Qt -I/root/rpi/mntrpi/usr/include/qt4/QtCore -c mainwindow.cpp
    arm-linux-gnueabihf-g++ -O0 -g -Wall -I./ -I/root/rpi/mntrpi/usr/include/qt4/ -I/root/rpi/mntrpi/usr/include/qt4/QtGui -I/root/rpi/mntrpi/usr/include/qt4/Qt -I/root/rpi/mntrpi/usr/include/qt4/QtCore -c tst.cpp
    moc-qt4 mainwindow.h -o mainwindow.moc.cpp
    arm-linux-gnueabihf-g++ -O0 -g -Wall -I./ -I/root/rpi/mntrpi/usr/include/qt4/ -I/root/rpi/mntrpi/usr/include/qt4/QtGui -I/root/rpi/mntrpi/usr/include/qt4/Qt -I/root/rpi/mntrpi/usr/include/qt4/QtCore -c mainwindow.moc.cpp
    moc-qt4 mainwindow.h -o tst.moc.cpp
    arm-linux-gnueabihf-g++ -O0 -g -Wall -I./ -I/root/rpi/mntrpi/usr/include/qt4/ -I/root/rpi/mntrpi/usr/include/qt4/QtGui -I/root/rpi/mntrpi/usr/include/qt4/Qt -I/root/rpi/mntrpi/usr/include/qt4/QtCore -c tst.moc.cpp
    arm-linux-gnueabihf-g++ -L/root/rpi/mntrpi/usr/lib/arm-linux-gnueabihf -L/root/rpi/mntrpi/usr/local/lib -lQtCore -lQtGui -Xlinker -rpath-link=/root/rpi/mntrpi/lib/arm-linux-gnueabihf -Xlinker -rpath-link=/root/rpi/mntrpi/usr/lib/arm-linux-gnueabihf -lQtNetwork -lpthread -lwiringPi main.o mainwindow.o tst.o mainwindow.moc.o tst.moc.o -o new_test
    tst.moc.o: In function `qt_noop()':
    /root/Desktop/new_test/tst.moc.cpp:41: multiple definition of `MainWindow::qt_static_metacall(QObject*, QMetaObject::Call, int, void**)'
    mainwindow.moc.o:/root/Desktop/new_test/mainwindow.moc.cpp:41: first defined here
    tst.moc.o:(.rodata+0x0): multiple definition of `MainWindow::staticMetaObjectExtraData'
    mainwindow.moc.o:(.rodata+0x0): first defined here
    tst.moc.o:(.rodata+0x8): multiple definition of `MainWindow::staticMetaObject'
    mainwindow.moc.o:(.rodata+0x8): first defined here
    tst.moc.o: In function `QScopedPointer<QObjectData, QScopedPointerDeleter<QObjectData> >::operator->() const':
    /root/Desktop/new_test/tst.moc.cpp:62: multiple definition of `MainWindow::metaObject() const'
    mainwindow.moc.o:/root/Desktop/new_test/mainwindow.moc.cpp:62: first defined here
    tst.moc.o: In function `MainWindow::qt_metacast(char const*)':
    /root/Desktop/new_test/tst.moc.cpp:67: multiple definition of `MainWindow::qt_metacast(char const*)'
    mainwindow.moc.o:/root/Desktop/new_test/mainwindow.moc.cpp:67: first defined here
    tst.moc.o: In function `MainWindow::qt_metacall(QMetaObject::Call, int, void**)':
    /root/Desktop/new_test/tst.moc.cpp:75: multiple definition of `MainWindow::qt_metacall(QMetaObject::Call, int, void**)'
    mainwindow.moc.o:/root/Desktop/new_test/mainwindow.moc.cpp:75: first defined here
    tst.moc.o:(.rodata+0x58): multiple definition of `vtable for MainWindow'
    mainwindow.moc.o:(.rodata+0x58): first defined here
    tst.moc.o:(.rodata+0x158): multiple definition of `typeinfo for MainWindow'
    mainwindow.moc.o:(.rodata+0x158): first defined here
    tst.moc.o:(.rodata+0x164): multiple definition of `typeinfo name for MainWindow'
    mainwindow.moc.o:(.rodata+0x164): first defined here
    tst.o: In function `tst::tst(QWidget*)':
    /root/Desktop/new_test/tst.cpp:9: undefined reference to `vtable for tst'
    /root/Desktop/new_test/tst.cpp:9: undefined reference to `vtable for tst'
    tst.o: In function `tst::~tst()':
    /root/Desktop/new_test/tst.cpp:14: undefined reference to `vtable for tst'
    /root/Desktop/new_test/tst.cpp:14: undefined reference to `vtable for tst'
    collect2: error: ld returned 1 exit status
    make: *** [all] Error 1
    rm mainwindow.moc.cpp tst.moc.cpp

    below i am displaying my files

    main.cpp

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

    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"

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

    MainWindow::~MainWindow()
    {
    delete ui;
    }
    /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
    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();

    private:
    Ui::MainWindow *ui;
    };

    #endif // MAINWINDOW_H

    //////////////////////////////////////////////////
    tst.cpp


    #include "tst.h"
    #include "ui_tst.h"

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

    tst::~tst()
    {
    delete ui;
    }
    /////////////////////////////////////////////////////////////////////////////////////////////////////////////
    tst.h

    #ifndef TST_H
    #define TST_H

    #include <QWidget>

    namespace Ui {
    class tst;
    }

    class tst : public QWidget
    {
    Q_OBJECT

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

    private:
    Ui::tst *ui;
    };

    #endif // TST_H

    ////////////////////////////////////////////////////////////////////////////////////////////////////

    Makefile

    ################################################## ###########################
    # Makefile for building: new_test
    # Generated by qmake (2.01a) (Qt 4.8.1) on: Mon Jan 4 15:21:41 2016
    # Project: new_test.pro
    # Template: app
    # Command: /usr/bin/qmake -o Makefile new_test.pro
    ################################################## ###########################

    ####### Compiler, tools and options


    CXX=arm-linux-gnueabihf-g++

    INCLUDEDIR = ./
    INCLUDEDIR += $(HOME)/rpi/mntrpi/usr/include/qt4/
    INCLUDEDIR += $(HOME)/rpi/mntrpi/usr/include/qt4/QtGui
    INCLUDEDIR += $(HOME)/rpi/mntrpi/usr/include/qt4/Qt
    INCLUDEDIR += $(HOME)/rpi/mntrpi/usr/include/qt4/QtCore
    #INCLUDEDIR += $(HOME)/rpi/mntrpi/usr/local/include
    #INCLUDEDIR += $(HOME)/rpi/mntrpi/usr/local/include
    #INCLUDEDIR += /usr/local/include

    #INCLUDEPATH += /mnt/rasp-pi-rootfs/usr/local/include
    #LIBS += -L/mnt/rasp-pi-rootfs/usr/local/lib -lwiringPi

    LIBRARYDIR = $(HOME)/rpi/mntrpi/usr/lib/arm-linux-gnueabihf
    LIBRARYDIR +=$(HOME)/rpi/mntrpi/usr/local/lib
    LIBRARY += QtCore QtGui
    XLINK_LIBDIR = $(HOME)/rpi/mntrpi/lib/arm-linux-gnueabihf
    #XLINK_LIBDIR += $(HOME)/rpi/mntrpi/usr/local/lib
    XLINK_LIBDIR += $(HOME)/rpi/mntrpi/usr/lib/arm-linux-gnueabihf
    #XLINK_LIBDIR += $(HOME)/rpi/mntrpi/usr/local/lib/

    INCDIR = $(patsubst %,-I%,$(INCLUDEDIR))
    LIBDIR = $(patsubst %,-L%,$(LIBRARYDIR))
    LIB = $(patsubst %,-l%,$(LIBRARY))
    XLINKDIR = $(patsubst %,-Xlinker -rpath-link=%,$(XLINK_LIBDIR))

    OPT = -O0
    DEBUG = -g
    WARN= -Wall
    PTHREAD= -lpthread
    GPIO = -lwiringPi
    QTGUI = -lQtGui
    QTNETWORK = -lQtNetwork
    QTCORE = -lQtCore

    CXXFLAGS= $(OPT) $(DEBUG) $(WARN) $(INCDIR)
    LDFLAGS= $(LIBDIR) $(LIB) $(XLINKDIR) $(QTNETWORK) $(PTHREAD) $(GPIO)

    INC = mainwindow.h tst.h
    SRC = main.cpp mainwindow.cpp tst.cpp

    OBJ = $(SRC:.cpp=.o) $(INC:.h=.moc.o)


    all: $(OBJ)
    $(CXX) $(LDFLAGS) $(OBJ) -o new_test


    %.moc.cpp: $(INC)
    moc-qt4 $< -o $@

    %.o:%.cpp
    $(CXX) $(CXXFLAGS) -c $<

    clean:
    -rm *.o
    -rm new_test

    /////////////////////////////////////////////////////////////////////////

  2. #2
    Join Date
    Jan 2008
    Location
    Alameda, CA, USA
    Posts
    5,230
    Thanks
    302
    Thanked 864 Times in 851 Posts
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: failed to crosscompiling with qt 4.8

    Did you run qmake after making changes to your project? Did you make clean as well before rebuilding?

Similar Threads

  1. Build failed
    By anh5kor in forum Newbie
    Replies: 1
    Last Post: 25th March 2015, 14:33
  2. compile Qt failed!
    By yleesun in forum Installation and Deployment
    Replies: 5
    Last Post: 24th July 2009, 04:47
  3. Qt 4.4.0 installation failed!!!!!
    By biswajithit in forum Installation and Deployment
    Replies: 1
    Last Post: 4th August 2008, 15:38
  4. Crosscompiling warnings
    By SteM in forum Installation and Deployment
    Replies: 1
    Last Post: 2nd August 2007, 20:26
  5. Crosscompiling QT
    By SteM in forum Installation and Deployment
    Replies: 1
    Last Post: 11th June 2007, 11:34

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.