Crosscompile app using external library



  • Hi, I want to crosscompile a Qt app to linux armv8.
    The app uses libusb to communicate with a periferic device and I need qmake use the right library version depending on the cpu architecture.
    I was reading the qmake Variables and Advanced Usage section for anwser and only found how to crosscompile between linux, mac and windows.
    Right now I'm using Ubuntu 16 x86_64, QtCreator 3.5.1 and Qt5.8. I already crosscompile Qt5.8 and libusb with linaro and set QtCreator to use the arm kit.
    Thanks in advance.


  • Moderators

    @Antonio-Ortiz

    You are probably missing something like this in your pro-file:

    win32:{
    include (../CompileSettings/BoostLib.inc)
    }
    linux:{
    INCLUDEPATH += . \
        "/home/xxxx/Source/boost_1_52_0"
    }
    linux-*:{
    INCLUDEPATH += . \
        "/home/xxxx/Source/boost_1_52_0"
    }
    

    You find several specifications for setups in mspecs folder of your specofoc Qt setup
    Here an example from windows

    c:\Qt\5.6\mingw49_32\mkspecs\linux-arm-gnueabi-g++ 
    

    It shows to the linux-arm-gnueabi-g++, which is a general specs for a cross compiler. For cross compiling your Qt you have used this or a similar. You have to give this name already during your configuration of the cross-compile. The example given above is basically distinguishing between a plain win32, a plain linux and a specific linux-* setup. The specific setup is a cross-compile setup, but I was simply too lazy to type the complete name and used a wildcard for qmake.

    As you see I am adding here the include path for the booth libs to the compilation. For you it has to be a specific path for the libraries.



  • Sorry for the late reply.
    I was trying with these lines on the pro, but still QtCreator load the x86_64 version of the library

    unix
    {
        armv8l
        {
            LIBS += -L$$PWD/../../../../../Aplicaciones/crosscompile/sysroot/usr/opt/libusb/lib/ -lusb-1.0
            INCLUDEPATH += $$PWD/../../../../../Aplicaciones/crosscompile/sysroot/usr/opt/libusb/include
            DEPENDPATH += $$PWD/../../../../../Aplicaciones/crosscompile/sysroot/usr/opt/libusb/include
        }
        armeabi-v8l
        {
            LIBS += -L$$PWD/../../../../../Aplicaciones/crosscompile/sysroot/usr/opt/libusb/lib/ -lusb-1.0
            INCLUDEPATH += $$PWD/../../../../../Aplicaciones/crosscompile/sysroot/usr/opt/libusb/include
            DEPENDPATH += $$PWD/../../../../../Aplicaciones/crosscompile/sysroot/usr/opt/libusb/include
        }
        armveabi-v7a
        {
            LIBS += -L$$PWD/../../../../../Aplicaciones/crosscompile/sysroot/usr/opt/libusb/lib/ -lusb-1.0
            INCLUDEPATH += $$PWD/../../../../../Aplicaciones/crosscompile/sysroot/usr/opt/libusb/include
            DEPENDPATH += $$PWD/../../../../../Aplicaciones/crosscompile/sysroot/usr/opt/libusb/include
        }
        gnueabihf
        {
            LIBS += -L$$PWD/../../../../../Aplicaciones/crosscompile/sysroot/usr/opt/libusb/lib/ -lusb-1.0
            INCLUDEPATH += $$PWD/../../../../../Aplicaciones/crosscompile/sysroot/usr/opt/libusb/include
            DEPENDPATH += $$PWD/../../../../../Aplicaciones/crosscompile/sysroot/usr/opt/libusb/include
        }
        gnueabihf-v8l
        {
            LIBS += -L$$PWD/../../../../../Aplicaciones/crosscompile/sysroot/usr/opt/libusb/lib/ -lusb-1.0
            INCLUDEPATH += $$PWD/../../../../../Aplicaciones/crosscompile/sysroot/usr/opt/libusb/include
            DEPENDPATH += $$PWD/../../../../../Aplicaciones/crosscompile/sysroot/usr/opt/libusb/include
        }
        beagle
        {
            LIBS += -L$$PWD/../../../../../Aplicaciones/crosscompile/sysroot/usr/opt/libusb/lib/ -lusb-1.0
            INCLUDEPATH += $$PWD/../../../../../Aplicaciones/crosscompile/sysroot/usr/opt/libusb/include
            DEPENDPATH += $$PWD/../../../../../Aplicaciones/crosscompile/sysroot/usr/opt/libusb/include
        }
        armhf
        {
            LIBS += -L$$PWD/../../../../../Aplicaciones/crosscompile/sysroot/usr/opt/libusb/lib/ -lusb-1.0
            INCLUDEPATH += $$PWD/../../../../../Aplicaciones/crosscompile/sysroot/usr/opt/libusb/include
            DEPENDPATH += $$PWD/../../../../../Aplicaciones/crosscompile/sysroot/usr/opt/libusb/include
        }
        x86_64
        {
            LIBS += -L"/usr/local/lib" -lusb-1.0
            INCLUDEPATH += /usr/include/libusb-1.0
            DEPENDPATH += /usr/include/libusb-1.0
        }
    
    }
    
    


  • Thans to your advice @koahnig I could find the solution. I write the g++ version I want to use in the .pro file and QtCreator star loading the right library's version. I put here the final .pro file

    linux-beagleboard-g++:{
        LIBS += -L /home/antonio/Aplicaciones/crosscompile/sysroot/usr/opt/libusb/lib/ -lusb-1.0
        INCLUDEPATH += /home/antonio/Aplicaciones/crosscompile/sysroot/usr/opt/libusb/include
        DEPENDPATH += /home/antonio/Aplicaciones/crosscompile/sysroot/usr/opt/libusb/include
    }
    unix:{
        LIBS += -L"/usr/local/lib" -lusb-1.0
        INCLUDEPATH += /usr/include/libusb-1.0
        DEPENDPATH += /usr/include/libusb-1.0
    }
    

  • Moderators

    @Antonio-Ortiz

    I am glad to see that you could solve your problem.

    The wildcard option is quite helpful, but also quite dangerous, if you are not very careful.