PDA

View Full Version : Deplying from QtCreator, and compiling



emartini
17th February 2010, 18:47
Hy you all guys!
I just started playing with QtCreator, and as you will see I REALLY a newbie...

Well, as a first try I did a small countdown program, from my home laptop. works like a charm.

Then I copied the file to a computer back in university and I get a "cannot run binary file" message (Ps: running linux on both machines).

I also tried to use static options (added CONFIG += static and staticlib to .pro file), file increases from 40k to 400k, but same message appears.

How I get this to work??

Also, if I want to compile my proj from shell, how I do it... tried make and g++ main.cpp , and none work...

Thanks for all help!!! =D

Lykurg
17th February 2010, 18:59
Hi, have a look at http://doc.trolltech.com/4.6/deployment-x11.html.

emartini
17th February 2010, 19:38
Hum, nice , I will take a look !!!

But, I think the biggest problem lies somewhere else, as a friend just pointed to me, I am on a 64 machine, while the other is a 32 one (ops...)
how I set QT creator to compile for other plataforms?

Lykurg
17th February 2010, 20:06
gcc has the options -m32 and -m64 to build for the different environments. Use QMAKE_CXXFLAGS to configure qmake in your *.pro file.

emartini
17th February 2010, 21:24
Ok, not quite working but some progress!

I am using flags :

QMAKE_CFLAGS += -m32
QMAKE_CXXFLAGS += -m32

and after meeting some missing dependencies I get the following message error, after using make from the terminal (MakeFile generated by QtCreator).


mainwindow.cpp:(.text._ZN13Ui_MainWindow7setupUiEP 11QMainWindow[Ui_MainWindow::setupUi(QMainWindow*)]+0x107): undefined reference to `operator new(unsigned int)'
mainwindow.cpp:(.text._ZN13Ui_MainWindow7setupUiEP 11QMainWindow[Ui_MainWindow::setupUi(QMainWindow*)]+0x167): undefined reference to `operator new(unsigned int)'
mainwindow.cpp:(.text._ZN13Ui_MainWindow7setupUiEP 11QMainWindow[Ui_MainWindow::setupUi(QMainWindow*)]+0x20e): undefined reference to `operator new(unsigned int)'
mainwindow.cpp:(.text._ZN13Ui_MainWindow7setupUiEP 11QMainWindow[Ui_MainWindow::setupUi(QMainWindow*)]+0x2af): undefined reference to `operator new(unsigned int)'
mainwindow.o:mainwindow.cpp:(.text._ZN13Ui_MainWin dow7setupUiEP11QMainWindow[Ui_MainWindow::setupUi(QMainWindow*)]+0x350): more undefined references to `operator new(unsigned int)' follow
moc_countdown.o: In function `countDown::qt_metacall(QMetaObject::Call, int, void**)':
moc_countdown.cpp:(.text+0x114): undefined reference to `std::basic_ostream<char, std::char_traits<char> >& std::__ostream_insert<char, std::char_traits<char> >(std::basic_ostream<char, std::char_traits<char> >&, char const*, int)'
moc_countdown.cpp:(.text+0x202): undefined reference to `operator new(unsigned int)'
moc_mainwindow.o:(.rodata._ZTV10MainWindow[vtable for MainWindow]+0xf4): undefined reference to `non-virtual thunk to QWidget::devType() const'
moc_mainwindow.o:(.rodata._ZTV10MainWindow[vtable for MainWindow]+0xf8): undefined reference to `non-virtual thunk to QWidget::paintEngine() const'
moc_mainwindow.o:(.rodata._ZTV10MainWindow[vtable for MainWindow]+0xfc): undefined reference to `non-virtual thunk to QWidget::metric(QPaintDevice::PaintDeviceMetric) const'
/usr/bin/ld: final link failed: Invalid operation
collect2: ld returned 1 exit status
make: *** [Pomodoro] Error 1


(after a lot of things that went ok, I found was too long and unnecessary to post...)

any ideas now??

Lykurg
17th February 2010, 21:29
how does your make file look like? (And just to be sure: have you cleaned your project after editing the pro file and rerun qmake&&make?)

emartini
17th February 2010, 23:39
Its a large MakeFile, so i am pasting only the main parameters (or what it seems to be):



C = gcc
CXX = g++
DEFINES = -DQT_GUI_LIB -DQT_CORE_LIB -DQT_SHARED
CFLAGS = -pipe -m32 -g -Wall -W -D_REENTRANT $(DEFINES)
CXXFLAGS = -pipe -m32 -g -Wall -W -D_REENTRANT $(DEFINES)
INCPATH = -I../../../../qtsdk-2010.01/qt/mkspecs/linux-g++-64 -I. -I../../../../qtsdk-2010.01/qt/include/QtCore -I../../../../qtsdk-20
10.01/qt/include/QtGui -I../../../../qtsdk-2010.01/qt/include -I. -I.
LINK = g++
LFLAGS = -m64 -Wl,-rpath,/home/emartini/qtsdk-2010.01/qt/lib
LIBS = $(SUBLIBS) -L/home/emartini/qtsdk-2010.01/qt/lib -lQtGui -L/home/emartini/qtsdk-2010.01/qt/lib -L/usr/X11R6/lib64 -lQtCore
-lpthread
AR = ar cqs
RANLIB =
QMAKE = /home/emartini/qtsdk-2010.01/qt/bin/qmake
TAR = tar -cf
COMPRESS = gzip -9f
COPY = cp -f
SED = sed
COPY_FILE = $(COPY)
COPY_DIR = $(COPY) -r
STRIP = strip
INSTALL_FILE = install -m 644 -p
INSTALL_DIR = $(COPY_DIR)
INSTALL_PROGRAM = install -m 755 -p
DEL_FILE = rm -f
SYMLINK = ln -f -s
DEL_DIR = rmdir
MOVE = mv -f
CHK_DIR_EXISTS= test -d
MKDIR = mkdir -p



by the way, I changed the code (irrelevant stuff, was organizing my classes, that were a mess), and removed the static libraries option I was using and got a simpler error:



g++ -c -pipe -m32 -g -Wall -W -D_REENTRANT -DQT_GUI_LIB -DQT_CORE_LIB -DQT_SHARED -I../../../../qtsdk-2010.01/qt/mkspecs/linux-g++-64 -I. -I../../../../qtsdk-2010.01/qt/include/QtCore -I../../../../qtsdk-2010.01/qt/include/QtGui -I../../../../qtsdk-2010.01/qt/include -I. -I. -o moc_countdown.o moc_countdown.cpp
g++ -m64 -Wl,-rpath,/home/emartini/qtsdk-2010.01/qt/lib -o Pomodoro main.o mainwindow.o countdown.o moc_mainwindow.o moc_countdown.o -L/home/emartini/qtsdk-2010.01/qt/lib -lQtGui -L/home/emartini/qtsdk-2010.01/qt/lib -L/usr/X11R6/lib64 -lQtCore -lpthread
collect2: ld terminated with signal 11 [Segmentation fault]
/usr/bin/ld: i386 architecture of input file `main.o' is incompatible with i386:x86-64 output
/usr/bin/ld: i386 architecture of input file `mainwindow.o' is incompatible with i386:x86-64 output
/usr/bin/ld: i386 architecture of input file `countdown.o' is incompatible with i386:x86-64 output
/usr/bin/ld: i386 architecture of input file `moc_mainwindow.o' is incompatible with i386:x86-64 output
/usr/bin/ld: i386 architecture of input file `moc_countdown.o' is incompatible with i386:x86-64 output
make: *** [Pomodoro] Error 1


And yes, I am doing make clean before compiling!

Does any of that shines a light?

Lykurg
17th February 2010, 23:44
Does any of that shines a light?
First command is with -m32, second with -m64. Seems not right to me... There must be any other flag to set but currently I don't know.

Lykurg
17th February 2010, 23:45
Ah, you have to change LFLAGS!

emartini
18th February 2010, 10:18
hum, sounds logical!!!!

Well I am at work now, as soon as I get home I will give it a try!
Thanks a lot, and I post any success here!

emartini
18th February 2010, 23:32
does not work.. :s

So... I tryed a couple of things after

first, just seeting LDFLAGS -= m64, LDFLAGS += m32 on .pro didn did ANYTHING! then changing it by hand on the make file i got


emartini@emartini1984:~/Documents/Projects/QTPomodoro$ make
g++ -m32 -Wl,-rpath,/home/emartini/qtsdk-2010.01/qt/lib -o Pomodoro main.o mainwindow.o countdown.o moc_mainwindow.o moc_countdown.o -L/home/emartini/qtsdk-2010.01/qt/lib -lQtGui -L/home/emartini/qtsdk-2010.01/qt/lib -L/usr/X11R6/lib64 -lQtCore -lpthread
/usr/bin/ld: skipping incompatible /home/emartini/qtsdk-2010.01/qt/lib/libQtGui.so when searching for -lQtGui
/usr/bin/ld: skipping incompatible /home/emartini/qtsdk-2010.01/qt/lib/libQtGui.so when searching for -lQtGui
/usr/bin/ld: skipping incompatible /home/emartini/qtsdk-2010.01/qt/lib/libQtCore.so when searching for -lQtCore
/usr/bin/ld: skipping incompatible /home/emartini/qtsdk-2010.01/qt/lib/libQtCore.so when searching for -lQtCore
emartini@emartini1984:~/Documents/Projects/QTPomodoro$ ./Pomodoro
Segmentation fault
emartini@emartini1984:~/Documents/Projects/QTPomodoro$

meaning, it compiles but not run (on any machine, neither 32 or 64)

then I went bananas and changed all 64's on Makefile to 32's (only 64 left is " INSTALL_FILE = install -m 644 -p", dont think it is related at all right?)

then I get :


emartini@emartini1984:~/Documents/Projects/QTPomodoro$ make
/home/emartini/qtsdk-2010.01/qt/bin/uic mainwindow.ui -o ui_mainwindow.h
g++ -c -pipe -m32 -g -Wall -W -D_REENTRANT -DQT_GUI_LIB -DQT_CORE_LIB -DQT_SHARED -I../../../../qtsdk-2010.01/qt/mkspecs/linux-g++-32 -I. -I../../../../qtsdk-2010.01/qt/include/QtCore -I../../../../qtsdk-2010.01/qt/include/QtGui -I../../../../qtsdk-2010.01/qt/include -I. -I. -o main.o main.cpp
g++ -c -pipe -m32 -g -Wall -W -D_REENTRANT -DQT_GUI_LIB -DQT_CORE_LIB -DQT_SHARED -I../../../../qtsdk-2010.01/qt/mkspecs/linux-g++-32 -I. -I../../../../qtsdk-2010.01/qt/include/QtCore -I../../../../qtsdk-2010.01/qt/include/QtGui -I../../../../qtsdk-2010.01/qt/include -I. -I. -o mainwindow.o mainwindow.cpp
mainwindow.cpp:35: warning: unused parameter ‘iconSize’
g++ -c -pipe -m32 -g -Wall -W -D_REENTRANT -DQT_GUI_LIB -DQT_CORE_LIB -DQT_SHARED -I../../../../qtsdk-2010.01/qt/mkspecs/linux-g++-32 -I. -I../../../../qtsdk-2010.01/qt/include/QtCore -I../../../../qtsdk-2010.01/qt/include/QtGui -I../../../../qtsdk-2010.01/qt/include -I. -I. -o countdown.o countdown.cpp
/home/emartini/qtsdk-2010.01/qt/bin/moc -DQT_GUI_LIB -DQT_CORE_LIB -DQT_SHARED -I../../../../qtsdk-2010.01/qt/mkspecs/linux-g++-32 -I. -I../../../../qtsdk-2010.01/qt/include/QtCore -I../../../../qtsdk-2010.01/qt/include/QtGui -I../../../../qtsdk-2010.01/qt/include -I. -I. mainwindow.h -o moc_mainwindow.cpp
g++ -c -pipe -m32 -g -Wall -W -D_REENTRANT -DQT_GUI_LIB -DQT_CORE_LIB -DQT_SHARED -I../../../../qtsdk-2010.01/qt/mkspecs/linux-g++-32 -I. -I../../../../qtsdk-2010.01/qt/include/QtCore -I../../../../qtsdk-2010.01/qt/include/QtGui -I../../../../qtsdk-2010.01/qt/include -I. -I. -o moc_mainwindow.o moc_mainwindow.cpp
/home/emartini/qtsdk-2010.01/qt/bin/moc -DQT_GUI_LIB -DQT_CORE_LIB -DQT_SHARED -I../../../../qtsdk-2010.01/qt/mkspecs/linux-g++-32 -I. -I../../../../qtsdk-2010.01/qt/include/QtCore -I../../../../qtsdk-2010.01/qt/include/QtGui -I../../../../qtsdk-2010.01/qt/include -I. -I. countdown.h -o moc_countdown.cpp
g++ -c -pipe -m32 -g -Wall -W -D_REENTRANT -DQT_GUI_LIB -DQT_CORE_LIB -DQT_SHARED -I../../../../qtsdk-2010.01/qt/mkspecs/linux-g++-32 -I. -I../../../../qtsdk-2010.01/qt/include/QtCore -I../../../../qtsdk-2010.01/qt/include/QtGui -I../../../../qtsdk-2010.01/qt/include -I. -I. -o moc_countdown.o moc_countdown.cpp
g++ -m32 -Wl,-rpath,/home/emartini/qtsdk-2010.01/qt/lib -o Pomodoro main.o mainwindow.o countdown.o moc_mainwindow.o moc_countdown.o -L/home/emartini/qtsdk-2010.01/qt/lib -lQtGui -L/home/emartini/qtsdk-2010.01/qt/lib -L/usr/X11R6/lib32 -lQtCore -lpthread
/usr/bin/ld: skipping incompatible /home/emartini/qtsdk-2010.01/qt/lib/libQtGui.so when searching for -lQtGui
/usr/bin/ld: skipping incompatible /home/emartini/qtsdk-2010.01/qt/lib/libQtGui.so when searching for -lQtGui
/usr/bin/ld: skipping incompatible /home/emartini/qtsdk-2010.01/qt/lib/libQtCore.so when searching for -lQtCore
/usr/bin/ld: skipping incompatible /home/emartini/qtsdk-2010.01/qt/lib/libQtCore.so when searching for -lQtCore
emartini@emartini1984:~/Documents/Projects/QTPomodoro$ ./Pomodoro
Segmentation fault
emartini@emartini1984:~/Documents/Projects/QTPomodoro$


Then I added -L/usr/lib32 to LIBS (directly on Makefile also), I get the same as before, but without the "skipping incompatible " lines , but same Segmentation fault...


Then i changed strategy, instead of QtCreator getting my make file, I did my "own" , used "qmake -o Makefile Pomodoro.pro", and it came out really different (what surprised me!)

my make file now gets like that


CC = gcc
CXX = g++
DEFINES = -DQT_NO_DEBUG -DQT_GUI_LIB -DQT_CORE_LIB -DQT_SHARED
CFLAGS = -pipe -m32 -O2 -Wall -W -D_REENTRANT $(DEFINES)
CXXFLAGS = -pipe -m32 -O2 -Wall -W -D_REENTRANT $(DEFINES)
INCPATH = -I/usr/share/qt4/mkspecs/linux-g++ -I. -I/usr/include/qt4/QtCore -I/usr/include/qt4/QtGui -I/usr/include/qt4 -I. -I.
LINK = g++
LFLAGS = -Wl,-O1
LIBS = $(SUBLIBS) -L/usr/lib32 -lQtGui -lQtCore -lpthread
AR = ar cqs
RANLIB =
QMAKE = /usr/bin/qmake
TAR = tar -cf
COMPRESS = gzip -9f
COPY = cp -f
SED = sed


then I get, after make



/usr/bin/uic-qt4 mainwindow.ui -o ui_mainwindow.h
g++ -c -pipe -m32 -O2 -Wall -W -D_REENTRANT -DQT_NO_DEBUG -DQT_GUI_LIB -DQT_CORE_LIB -DQT_SHARED -I/usr/share/qt4/mkspecs/linux-g++ -I. -I/u
sr/include/qt4/QtCore -I/usr/include/qt4/QtGui -I/usr/include/qt4 -I. -I. -o main.o main.cpp
g++ -c -pipe -m32 -O2 -Wall -W -D_REENTRANT -DQT_NO_DEBUG -DQT_GUI_LIB -DQT_CORE_LIB -DQT_SHARED -I/usr/share/qt4/mkspecs/linux-g++ -I. -I/u
sr/include/qt4/QtCore -I/usr/include/qt4/QtGui -I/usr/include/qt4 -I. -I. -o mainwindow.o mainwindow.cpp
g++ -c -pipe -m32 -O2 -Wall -W -D_REENTRANT -DQT_NO_DEBUG -DQT_GUI_LIB -DQT_CORE_LIB -DQT_SHARED -I/usr/share/qt4/mkspecs/linux-g++ -I. -I/u
sr/include/qt4/QtCore -I/usr/include/qt4/QtGui -I/usr/include/qt4 -I. -I. -o countdown.o countdown.cpp
/usr/bin/moc-qt4 -DQT_NO_DEBUG -DQT_GUI_LIB -DQT_CORE_LIB -DQT_SHARED -I/usr/share/qt4/mkspecs/linux-g++ -I. -I/usr/include/qt4/QtCore -I/us
r/include/qt4/QtGui -I/usr/include/qt4 -I. -I. mainwindow.h -o moc_mainwindow.cpp
g++ -c -pipe -m32 -O2 -Wall -W -D_REENTRANT -DQT_NO_DEBUG -DQT_GUI_LIB -DQT_CORE_LIB -DQT_SHARED -I/usr/share/qt4/mkspecs/linux-g++ -I. -I/u
sr/include/qt4/QtCore -I/usr/include/qt4/QtGui -I/usr/include/qt4 -I. -I. -o moc_mainwindow.o moc_mainwindow.cpp
/usr/bin/moc-qt4 -DQT_NO_DEBUG -DQT_GUI_LIB -DQT_CORE_LIB -DQT_SHARED -I/usr/share/qt4/mkspecs/linux-g++ -I. -I/usr/include/qt4/QtCore -I/us
r/include/qt4/QtGui -I/usr/include/qt4 -I. -I. countdown.h -o moc_countdown.cpp
g++ -c -pipe -m32 -O2 -Wall -W -D_REENTRANT -DQT_NO_DEBUG -DQT_GUI_LIB -DQT_CORE_LIB -DQT_SHARED -I/usr/share/qt4/mkspecs/linux-g++ -I. -I/u
sr/include/qt4/QtCore -I/usr/include/qt4/QtGui -I/usr/include/qt4 -I. -I. -o moc_countdown.o moc_countdown.cpp
g++ -Wl,-O1 -o Pomodoro main.o mainwindow.o countdown.o moc_mainwindow.o moc_countdown.o -L/usr/lib32 -lQtGui -lQtCore -lpthread

bla bla bla bla bla (a lot of the errors that are to come...

countdown.cpp:(.text+0xc7c): undefined reference to `std::basic_ostream<char, std::char_traits<char> >& std::__ostream_insert<char, std::char_traits<char> >(std::basic_ostream<char, std::char_traits<char> >&, char const*, int)'
countdown.o: In function `countDown::~countDown()':
countdown.cpp:(.text+0xe5c): undefined reference to `std::basic_ostream<char, std::char_traits<char> >& std::__ostream_insert<char, std::char_traits<char> >(std::basic_ostream<char, std::char_traits<char> >&, char const*, int)'
countdown.o:countdown.cpp:(.text+0x103c): more undefined references to `std::basic_ostream<char, std::char_traits<char> >& std::__ostream_insert<char, std::char_traits<char> >(std::basic_ostream<char, std::char_traits<char> >&, char const*, int)' follow
moc_mainwindow.o:(.rodata._ZTV10MainWindow[vtable for MainWindow]+0xf4): undefined reference to `non-virtual thunk to QWidget::devType() const'
moc_mainwindow.o:(.rodata._ZTV10MainWindow[vtable for MainWindow]+0xf8): undefined reference to `non-virtual thunk to QWidget::paintEngine() const'
moc_mainwindow.o:(.rodata._ZTV10MainWindow[vtable for MainWindow]+0xfc): undefined reference to `non-virtual thunk to QWidget::metric(QPaintDevice::PaintDeviceMetric) const'
/usr/bin/ld: final link failed: Invalid operation
collect2: ld returned 1 exit status
make: *** [Pomodoro] Error 1


this approach seemed more promissing to me (I am beggining to get suspicious with QtCreator compilation )
but I could not figure this link failure, googling some people have this problem if they had .o files from different architecture, like if they generate them in a 64 and then try to link on a 32... but here this doesn't apply (I guess...)

Well, if anyone gets a clue what is the problem here I would really appreciate!

and sorry for the flooding! :D :o

Lykurg
19th February 2010, 08:58
in the first your program compiles only ld was not working. There I guess you have to link against the 32 bit libraries of Qt. Try to install Qt for 32 parallel to your installation and build with them when building for 32 bit architecture.

emartini
20th February 2010, 00:34
Try to install Qt for 32 parallel to your installation and build with them when building for 32 bit architecture.

ok.... I got Qt source from the official web site... I notice on config that I can choose the folders where to install with -prefix option right? that will give me the parallel instalation u mean!? (is it really just that, or would that mess up my previous installation?)

But found nothing (on configure) on how to compile to 32!!! or should I just get the make file and add all those -L/usr/lib32 -m32 in their places ?