0

I've a simple Qt helloworld.cpp that I cross compiled for armv7l using Linaro GCC arm-linux-gnueabihf-g++ on Ubuntu 16.04 and copied the file on a target ARM board running Linux Kernel 4.4, GCC 5.3. The target is TI Vayu ES 2.0 (which has ARM Cortex A15 core).

Source

helloworld.cpp
    #include <QApplication>
    #include <QLabel>
    int main(int argc, char **argv){
        QApplication app(argc,argv);
        QLabel label("Hello World");
        label.show();
        return app.exec();
    } 
helloworld.pro
    QT += core gui widgets
    SOURCES += helloworld.cpp 

Build:

patel@11:02:43~$make
arm-linux-gnueabi-g++ -c -pipe -O2 -std=gnu++11 -Wall -W -D_REENTRANT -fPIC -DQT_NO_DEBUG -DQT_WIDGETS_LIB -DQT_GUI_LIB -DQT_CORE_LIB -I. -I/opt/Qt5.7/Qt-v5.7.1-armv7l/include -I/opt/Qt5.7/Qt-v5.7.1-armv7l/include/QtWidgets -I/opt/Qt5.7/Qt-v5.7.1-armv7l/include/QtGui -I/opt/Qt5.7/Qt-v5.7.1-armv7l/include/QtCore -I. -I/opt/Qt5.7/Qt-v5.7.1-armv7l/mkspecs/linux-arm-gnueabi-g++ -o helloworld.o helloworld.cpp
arm-linux-gnueabi-g++ -Wl,-O1 -Wl,-rpath,/opt/Qt5.7/Qt-v5.7.1-armv7l/lib -o helloworld helloworld.o   -L/opt/Qt5.7/Qt-v5.7.1-armv7l/lib -lQt5Widgets -lQt5Gui -lQt5Core -lpthread 

Other debug info:

patel@11:04:06~$file helloworld
helloworld: ELF 32-bit LSB executable, ARM, EABI5 version 1 (SYSV), dynamically linked, interpreter /lib/ld-linux.so.3, for GNU/Linux 3.2.0, BuildID[sha1]=e4f5148d70a7ad793c951f68b398ee7f9a4d9069, not stripped
patel@11:04:11~$readelf -a helloworld | grep interpreter
      [Requesting program interpreter: /lib/ld-linux.so.3]
patel@11:04:45~$objdump -x helloworld | grep NEEDED
  NEEDED               libQt5Widgets.so.5
  NEEDED               libQt5Core.so.5
  NEEDED               libstdc++.so.6
  NEEDED               libc.so.6
  NEEDED               ld-linux.so.3

SCP the file to the target ARM board and trying to run it.

root@dra7xx-evm:~# ls -l
-rwxr-xr-x    1 root     root         16792 Oct  7 15:07 helloworld
-rwxr-xr-x    1 root     root          9784 Oct  7 14:22 helloworld-arm
-rwxr-xr-x    1 root     root          9784 Oct  7 14:21 helloworld-gcc
-rwxr-xr-x    1 root     root         16792 Oct  7 15:06 helloworld-qt

root@dra7xx-evm:~# ./helloworld
-sh: ./helloworld: No such file or directory

This post had a similar problem to mine and I did try creating a symlink for ld-linux.so.3 like this and tried to run again -

root@dra7xx-evm:/lib# ln -s ld-2.21.so ld-linux.so.3
root@dra7xx-evm:/lib# cd -
root@dra7xx-evm:~# ./helloworld
Segmentation fault (core dumped)

What am I doing wrong here or missing any lib?

Community
  • 1
  • 1
kaushal
  • 785
  • 12
  • 27
  • 5
    ISSUE: The ARM *rootfs* that you have on the build machine doesn't match the target. You can run your `ld` with [*LD_DEBUG=all*](http://www.bnikolic.co.uk/blog/linux-ld-debug.html) to see the issues. However, the best way is to get an ARM cross compiler that is targeting your target. The libc, os and compiler need to match; it is possible to run them with mismatched versions in some cases, but if you don't understand things you should be sure they match as exactly as possible. The "needed" files should exist on your build machine; copy them to the target (hope the OS is ok?). No symlink! – artless noise Oct 07 '16 at 17:11
  • @artlessnoise thanks, I'll check that. I'll admit I'm new to all this and still learning about cross compiling as I go – kaushal Oct 07 '16 at 18:04
  • Is the target 64 bit? Your file command shows the executable as 32 bit. Have seen simelar File not found issus on 64bit Desktops running 32bit code – eactor Oct 11 '16 at 20:28
  • The target is 32 bit armv7l core. And I'm trying to run the files on the target only. – kaushal Oct 12 '16 at 14:18

0 Answers0