2

I want to use a Qt app on a tiny210 device.

I installed Qt ( qt-everywhere-opensource-src.4.8.5 ) downloaded from here. I managed to compile a simple application for use on tiny210. The problem is that now when I try to run the app on the device, I get the following errors:

libc.so.6: version 'GLIBC_2.15' not found (required by libQtCore.so.4)
libc.so.6: version 'GLIBC_2.15' not found (required by libQtNetwork.so.4)

There is a libc.so.6 in /lib/ on the target device, but it is version 2.11.

I should mention that before getting those errors I also got errors for not having libQtCore.so.4, libQtNetwork.so.4 and libQtGui.so.4. I fixed those errors just by copying the compiled libraries from my host PC to the device.

First question is: Would there have been a better way to provide the needed libraries, or copying them is fine?

Second question is: How can I get over the errors mentioned above?

EDIT : I've read something about building it static, but I am not sure how, and what are the downsides of this.

EDIT2 : I managed to get over the above errors thanks to artless noise's answer, but now I get: error loading shared libraries: libQtGui.so.4: cannot open shared object file: No such file or directory.

N Alex
  • 1,014
  • 2
  • 18
  • 29
  • did you compile Qt from source on your host PC? you need to compile with the config of the chip to get the correct libraries.Did you follow those instructions : http://qt-project.org/doc/qt-4.8/qt-embedded-crosscompiling.html ? – UmNyobe Jan 08 '14 at 12:10
  • I didn't use anything specific fom the tiny210, I just ran `./configure -opensource -confirm-license -no-pch -embedded arm -platform qws/linux-x86_64-g++ -xplatform linux-arm-gnueabi-g++ -little-endian -no-webkit`. The cross-compiler was installed from the software-center (`apt-get install gcc-arm-linux-gnueabi`). Maybe I got this wrong. I am pretty new to cross-compiling and Qt, just started a couple of weeks ago. I followed the guide, but for example I did nothing for step 3 (other than the things mentioned above). – N Alex Jan 08 '14 at 12:30
  • the least paintful thing will be to build on a old linux (which has the same version of the gnu c library). It is a bit uncomfortable, as you will move your development to that platform. – UmNyobe Jan 08 '14 at 12:39
  • I was thinking that maybe there is a way to include all the needed libraries in the final executable. It probably will get bigger, but that's not a problem. Or somehow to update the needed libraries on the device. – N Alex Jan 08 '14 at 12:42
  • `libc` is the standard C library. You can hardly get more basic than that. Copying it is a mistake. – UmNyobe Jan 08 '14 at 12:46
  • I didn't mean to copy it, but somehow make the device use another version only for this App, or compile it with the older version. Trying with an old distribution of linux would be a last resort. – N Alex Jan 08 '14 at 12:54

1 Answers1

1

The issue is the cross-compiler (apt-get install gcc-arm-linux-gnueabi) is ARM based and this cross compiler has a newer glibc than on the ARM device. You can copy the libc from the cross compiler directory to your ARM device. I suggest testing with LD_LIBRARY_PATH, before updating the main libraries. Use ls /var/lib/dpkg/info/*arm-linux*.list to see most packages related to the ARM compiler. You can use grep to figure out where the libraries are (or fancier things like apt-file, etc).

Crosstool-ng has a populate script, but I dont see it in the Ubuntu packages; it is perfect for your issue. If it is present on your Debian version, I would use it.

The glibc 2.15 is backwards compatible with the glibc 2.11 which is currently on your system. Issues may arise if the compiler was configured with different options (different ABI); however if this is the case, you will have many issues with your built Qt besides the library. In this case, you need to find a better compiler which fits your root filesystem.

So to be clear, on the target

  mkdir /lib/staging
  cp libc.so-2.15 /lib/staging
  cd /lib/staging
  ln -s libc.so-2.15 libc.so
  LD_LIBRARY_PATH=/lib/staging ls  # test the library

You may have to copy additional libraries, such as pthread, resolv, rt, crypt, etc. The files are probably in a directory like sysroot/lib. You can copy the whole directory to the /lib/staging to test it. If the above ls functions, then the compilers should be ABI compatible. If you have a crash or not an executable, then the compiler and rootfs may not be compatible.

Would there have been a better way to provide the needed libraries, or copying them is fine?

Copying may be fine as per above. If it is not fine, then either the compiler or the root filesystem must be updated.

How can I get over the errors mentioned above?

Try the above method. As well, you maybe able to leave your root filesystem alone. Set-up a shadow directory and use chroot to run the Qt application with the copied files as another solution. To test this, make a very simple program and put it along the compiler libraries in a test directory, say /lib/staging as above. Then the test code can be run like,

 $ LD_LIBRARY_PATH=/lib/staging ./hello_world

If this doesn't work, your compiler and the ARM file system/OS are not compatible. No library magic will help.

I've read something about building it static, but I am not sure how, and what are the downsides of this.

See Linux static linking is dead. I understand this seems like a solution. However, if the compiler is wrong, this won't help. The calling convention between OS, libraries and what registers are saved by the OS will be implicit in the compiled code. You may have to rebuild Qt with -softfp, etc.

Community
  • 1
  • 1
artless noise
  • 21,212
  • 6
  • 68
  • 105
  • I can't manage to copy the file on the device. Getting `Segmentation Fault` when trying to copy it. I posted another question to find out why, but in the meantime do you know how can I make the binary file include all the libraries so it can be stand-alone? – N Alex Jan 08 '14 at 16:48
  • I tried what you suggested, but I cannot find how to modify LD_LIBRARY_PATH. It is a strange flavor of linux installed on it, and can't really find how. – N Alex Jan 08 '14 at 17:58
  • I managed in the end to put /lib/staging on the LD_LIBRARY_PAT, so now I got over the errors presented in the Question, but now I get `error loading shared libraries: libQtGui.so.4: cannot open shared object file: No such file or directory`. It is strange that it sees `libQtCore` and `libQtNetwork`, but not this. Do you have any idea why? – N Alex Jan 08 '14 at 18:19
  • It maybe links or something else. As well as `LD_LIBRARY_PATH`, you may use `LD_DEBUG=all` and this might help you solve your issue. Again, this is in `man ld.so` on the PC. I recommend reading that :) A simple *hello world* executable might allow you to proceed in steps. – artless noise Jan 08 '14 at 18:30
  • Shouldn't `ln -s libc.so libc.so-2.15` be `ln -s libc.so-2.15 libc.so ` ? – N Alex Jan 13 '14 at 12:02
  • And shouldn't there be a file `libc.so.6` in that folder? Your advice was good, but I found out later, that it still doesn't load my `libc`, but only the other libraries in that folder. I posted [another question here](http://stackoverflow.com/questions/21092204/how-to-use-newer-libc-library). – N Alex Jan 13 '14 at 15:33
  • I don't have your exact libraries, so everything I wrote was a guess. The versioning will be different with each *glibc* release and some people may not use *glibc*, but *klibc*, *uclibc*, *eglibc*, etc. Copying the whole directory in *sysroot/lib* should have had all the links setup for your compiler. I meant that section as an pseudo-example, not a script to run. – artless noise Jan 13 '14 at 16:26