ant1bball
Posts: 9
Joined: Fri May 03, 2013 8:11 am
Location: Madrid, Spain

Run Executable compiled in Ubuntu

Fri May 03, 2013 8:19 am

I am using Qt in Ubuntu 12.04 in my laptop to create an executable file for linux. However, when i copy this to my raspberry pi (running on raspbian wheezy) and try to execute it i just get the message: "cannot execute binary file". The file runs fine on ubuntu.
Do I have to compile everything all over again in the raspberry pi using the original .cpp and header files or is there a way to just get a file which i can execute directly in the pi without messing around?

Thanks.

jamesh
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 30149
Joined: Sat Jul 30, 2011 7:41 pm

Re: Run Executable compiled in Ubuntu

Fri May 03, 2013 8:55 am

You laptop almost certainly uses a x86 processor, the Raspi uses an ARM processor. Binary executables for one will not work on the other. You can either compile the code on the Raspi, or install a cross compiler on the Ubuntu box (which will be much faster at compiling), and produce binary files that work.

There is the 'file' (IIRC) command in linux that tells you what the executable was built for.
Principal Software Engineer at Raspberry Pi (Trading) Ltd.
Working in the Applications Team.

ant1bball
Posts: 9
Joined: Fri May 03, 2013 8:11 am
Location: Madrid, Spain

Re: Run Executable compiled in Ubuntu

Fri May 03, 2013 2:13 pm

Thanks, i'll try this tutorial see if its any use: https://gitorious.org/raspberry-qt/rasp ... README.txt

ant1bball
Posts: 9
Joined: Fri May 03, 2013 8:11 am
Location: Madrid, Spain

Re: Run Executable compiled in Ubuntu

Tue May 07, 2013 10:01 am

Ok the tutorial works, successfuly cross-compiled and ran the example on the pi. However, when I run my Qt GUI application, it loads on the pi with the following effect:
· I get a full screen window instead of the small window i got running it on my PC
· All the buttons of my interface lose their text, plus they cant be clicked
· The mouse disappears (this also happens with the example from the tutorial)

The only way to exit the screen is to stop running the program from the PC (this also happens with the example)

User avatar
topguy
Posts: 7240
Joined: Tue Oct 09, 2012 11:46 am
Location: Trondheim, Norway

Re: Run Executable compiled in Ubuntu

Thu May 09, 2013 3:15 pm

Qt5 has different rendering platforms, and probably the standard for your compiled version is "eglfs" (EGL 2.0), which is fullscreen EGL accelerated mobile application style.

if you run your program with the option "-platform bullshot" it should list out all the supported rendering platforms. Choosing "x11" or "xcb" as rendering platform will probably result in something what you expect.

ant1bball
Posts: 9
Joined: Fri May 03, 2013 8:11 am
Location: Madrid, Spain

Re: Run Executable compiled in Ubuntu

Fri May 10, 2013 9:19 am

Firstly thanks for the reply. Indeed the standard for my compiled version is "eglfs" (EGL 2.0), which is fullscreen EGL accelerated mobile application style. I couldn't use x11 or xcb, since they were not available options. The options i had were: eglfs, linuxfb, minimal, minimalegl, offscreen. None of these worked properly, moreover, most of them returned: "this plugin does not support propagateSizeHints()". Does this mean i have to install xcb or x11? These should be installed in the pi or in Qt which then deploys it to the pi when I run the program?

User avatar
topguy
Posts: 7240
Joined: Tue Oct 09, 2012 11:46 am
Location: Trondheim, Norway

Re: Run Executable compiled in Ubuntu

Fri May 10, 2013 11:55 pm

From the script on gitourios you said you used I can see that a lot of xcb libraries are installed in step 1.

But I think you have to add something to the ./configure line in step 4. to get it to actually build with xcb support, try "./configure --help" or google for it.

And you will have to have X windows running when trying to run your program.

Personally I use pre-compiled Qt5 packages from twolife.be ( I mention it in every thread about Qt5 so just search the forum.) but I have not tested the xcb support of those packages yet.

ant1bball
Posts: 9
Joined: Fri May 03, 2013 8:11 am
Location: Madrid, Spain

Re: Run Executable compiled in Ubuntu

Mon May 13, 2013 8:16 am

I ran ./configure --help in the qtbase directory (dont know if I have to do it on the ./configure qt5 directory instead), there where 3 interesting options:
-xcb ................ Compile Xcb support.
-qt-xcb ............ Use xcb- libraries bundled with Qt.
(libxcb.so will still be used from operating system).
-system-xcb ........ Use xcb- libraries from the operating system.

When I ran the first one I got:

This is the Qt Open Source Edition.

You are licensed to use this software under the terms of
the Lesser GNU General Public License (LGPL) versions 2.1.

You have already accepted the terms of the license.

<srcbase> = /home/toni/opt/qt5/qtbase
<outbase> = /home/toni/opt/qt5/qtbase
Creating qmake...
make: No se hace nada para «first».
Running configuration tests...
Note: PKG_CONFIG_LIBDIR automatically set to /mnt/rasp-pi-rootfs/usr/lib/pkgconfig:/mnt/rasp-pi-rootfs/usr/share/pkgconfig:/mnt/rasp-pi-rootfs/usr/lib/arm-linux-gnueabihf/pkgconfig
Note: PKG_CONFIG_SYSROOT_DIR automatically set to /mnt/rasp-pi-rootfs
The test for linking against libxcb failed!
You might need to install dependency packages for libxcb.
See src/plugins/platforms/xcb/README.


However, when I run: sudo apt-get install "^libxcb.*" libx11-xcb-dev libglu1-mesa-dev libxrender-dev it says all my libxcb are up to date.... Might this be happening because the dependency packages? or maybe because the lib directory is set to the /mnt/rasp-pi-rootfs/... instead of my /usr/lib/i386-linux-gnu???

User avatar
topguy
Posts: 7240
Joined: Tue Oct 09, 2012 11:46 am
Location: Trondheim, Norway

Re: Run Executable compiled in Ubuntu

Wed May 15, 2013 3:01 pm

http://qt-project.org/forums/viewthread/10466

I found this post which is somewhat related. You could try that "apt-get" command in first reply to see if that fixes it.

But yes, It might be that you also need to install more on your RasPi-rootfs.

ant1bball
Posts: 9
Joined: Fri May 03, 2013 8:11 am
Location: Madrid, Spain

Re: Run Executable compiled in Ubuntu

Thu May 16, 2013 7:38 am

Unfortunatelly that apt-get install only lets me know all my libraries are already installed? I guess the question is how do I install the xcb support on the pi image not on my OS (where it is already installed).

User avatar
topguy
Posts: 7240
Joined: Tue Oct 09, 2012 11:46 am
Location: Trondheim, Norway

Re: Run Executable compiled in Ubuntu

Fri May 17, 2013 7:58 pm

The only way I know to do that is to write the image to a SD-card, boot it on a real Pi, do an apt-get update+upgrade, + install the missing libs. And then read the SD-card back again as an new image and mount that one instead.

ant1bball
Posts: 9
Joined: Fri May 03, 2013 8:11 am
Location: Madrid, Spain

Re: Run Executable compiled in Ubuntu

Thu May 23, 2013 11:46 am

Ok i formated all my ubuntu partition and started all over again following this:
http://creeder.com/?page=RaspberryPi
Not the tutorial says it doesnt support webkit which is fine because i dont need it

Indeed I updated, upgraded, then installed all he xcb libraries on the raspberry pi, then mounted the modified image in the pc. I went into /opt/qt5/qtbase and ran ./configure with the options specified by the tutorial plus the -xcb (xcb support) and -no-pch (to avoid the cc1: fatal error: .pch/release-shared/QtGui: No such file or directory). Then ran sudo make -j 4 and sudo make install correctly. The I have to move on to the qt4 directory and ran sudo make, ran into an error because it couldnt find InspectorBackendCommands.qrc in the folder /qt5/qtwebkit//Source/Webcore/generated. I found that file in /qt5/qtwebkit/source/webcore/inspect/front end, so i copied it and pasted it in the /qt5/qtwebkit//Source/Webcore/generated folder, the sudo make worked fine then. Finally I ran sudo make install and ran into this error:

Code: Select all

[color=#0000BF]In file included from ../WTF/wtf/unicode/Unicode.h:34:0,
                 from ../WTF/wtf/text/ASCIIFastPath.h:30,
                 from ../WTF/wtf/text/WTFString.h:28,
                 from yarr/YarrPattern.h:33,
                 from yarr/YarrInterpreter.h:29,
                 from yarr/YarrInterpreter.cpp:28:
../WTF/wtf/unicode/icu/UnicodeIcu.h:27:27: fatal error: unicode/uchar.h: No existe el archivo o el directorio
compilation terminated.[/color]
The UnicodeIcu file has the following includes:

Code: Select all

[color=#0000BF]#include <stdlib.h>                //line 26
#include <unicode/uchar.h>           //line 27          
#include <unicode/uscript.h>           //line 28
#include <unicode/ustring.h>           //line 29
#include <unicode/utf16.h>              //line 30[/color]


uchar.h contains:

Code: Select all

[color=#0000BF]#include "unicode/utypes.h"[/color]
Which is weird because when i go to /usr/include/unicode there is a uchar.h. Just in case I copied the folder unicode contents to /home/tony/opt/qt5/qtwebkit/Source/WTF/wtf/unicode/icu/unicode so there is also a uchar.h, but it still gives the same error. What is wrong? maybe it is looking in the /mnt/rasp-pi-rootfs/usr/include (where there is no unicode folder) instead of the pc's /usr/include (where there is a unicode folder). Maybe it has something to do with webkit? The tutorial says it doesnt provide webkit, but in the configure i cant see any -no-qtwebkit options.

Thank you in advance, you are being great help

Return to “C/C++”