furkantokac / buildroot

Buildroot fork customized for RPI3, iMX6, TK1, Qt, FastBoot.
Other
157 stars 37 forks source link

Static compile of QT programm cannot find -lbcm_host libEGL.so #6

Closed MarkusIppy closed 4 years ago

MarkusIppy commented 4 years ago

I follwed the tutorial on your website . I can succesfully compile the image with buildroot . When i try then to compile my programm static i get these two errors .

My .pro file has the following added :+1: QMAKE_LFLAGS += -static

My output fails for linking -lbcm_host and libEGL.so

/home/develop/buildroot/output/host/lib/gcc/arm-buildroot-linux-gnueabihf/7.4.0/../../../../arm-buildroot-linux-gnueabihf/bin/ld: cannot find -lbcm_host /home/develop/buildroot/output/host/lib/gcc/arm-buildroot-linux-gnueabihf/7.4.0/../../../../arm-buildroot-linux-gnueabihf/bin/ld: attempted static link of dynamic object `/home/develop/buildroot/output/host/arm-buildroot-linux-gnueabihf/sysroot/usr/lib/libEGL.so'

Sorry if this might be a very noobish question

furkantokac commented 4 years ago

You don't need QMAKE_LFLAGS += -static, if qtbase is compiled statically, it'll automatically compile the Qt programs statically.

Follow the steps to compile a Qt program without without an issue;

  1. Follow the steps in "Build RPI3 fastboot distro + static Qt" https://github.com/furkantokac/buildroot#build-rpi3-fastboot-distro--static-qt
  2. Download the test project https://github.com/furkantokac/QmlTest/blob/master/QmlTestApplication.pro
  3. Run compiled qmake in the directory of the test project and then make. Your command should look something like this cd /home/username/QmlTestApplication; /home/username/buildroot/output/qt/qt-everywhere-src-*/aaaout/bin/qmake; make
  4. Binary file should be ready to run on Raspberry.

The thing is you need to have all the plugins you used in the .pro file to make them included in the statically compiled binary file. For example, this QTPLUGIN.platforms += qeglfs qxcb qlinuxfb command makes the binary file include platform plugins inside of the statically compiled binary file.