Using WiringPi on CM3+ module



  • Hi All,

    I'm sure I have a simple problem but my lack of programming skills is making me pull my hair out.

    I'm trying to use the wiringPi library to interface into the raspberry compute module, this is a cross compile application (through I don't think this is relevant factor here). I have used Yocto to build the CM3+ image and on my development machine (Ubuntu 18.04.2 LTS) I'm using the bitbake toolchain with Qt Creator 4.9.2

    I have added these lines to my .pro file

    # These next three lines allow for the use of wiringPi
    INCLUDEPATH += /opt/poky/2.6.1/sysroots/cortexa7t2hf-neon-vfpv4-poky-linux-gnueabi/usr/include
    LIBS += -L"/opt/poky/2.6.1/sysroots/cortexa7t2hf-neon-vfpv4-poky-linux-gnueabi/usr/lib"
    LIBS += -lwiringPi
    

    This has allowed me to use the "#include <wiringPi.h>" directive, which it finds and when I compile I'm sure that it links OK, however it throws out the following error:

    /opt/poky/2.6.1/sysroots/x86_64-pokysdk-linux/usr/libexec/arm-poky-linux-gnueabi/gcc/arm-poky-linux-gnueabi/8.2.0/real-ld:-1: error: cannot find /lib/libc.so.6
    
    /opt/poky/2.6.1/sysroots/x86_64-pokysdk-linux/usr/libexec/arm-poky-linux-gnueabi/gcc/arm-poky-linux-gnueabi/8.2.0/real-ld:-1: error: cannot find /usr/lib/libc_nonshared.a
    
    /opt/poky/2.6.1/sysroots/x86_64-pokysdk-linux/usr/libexec/arm-poky-linux-gnueabi/gcc/arm-poky-linux-gnueabi/8.2.0/real-ld:-1: error: cannot find /lib/ld-linux-armhf.so.3
    

    I have done a "find" for these files and they are in the toolchain as shown:

    ./opt/poky/2.6.1/sysroots/cortexa7t2hf-neon-vfpv4-poky-linux-gnueabi/lib/libc.so.6
    ./opt/poky/2.6.1/sysroots/cortexa7t2hf-neon-vfpv4-poky-linux-gnueabi/usr/lib/libc_nonshared.a
    ./opt/poky/2.6.1/sysroots/cortexa7t2hf-neon-vfpv4-poky-linux-gnueabi/lib/ld-linux-armhf.so.3

    My question is why are they not picked up with QT creator?? I'm sure the answer is going to show my lack of linux or QT creator skills, but any help would be much appreciated.

    Am I simply missing something from a path statement??

    Kind regards
    Steve.



  • OK, so here is what I have figured out so far.......

    After searching the net for some time, I found that within the libc.so file there was:

    /* GNU ld script
       Use the shared library, but some functions are only in
       the static library, so try that secondarily.  */
    OUTPUT_FORMAT(elf32-littlearm)
    GROUP ( /lib/libc.so.6 /usr/lib/libc_nonshared.a  AS_NEEDED ( /lib/ld-linux-armhf.so.3 ) )
    

    so I changed this to make the paths relative as in:

    /* GNU ld script
       Use the shared library, but some functions are only in
       the static library, so try that secondarily.  */
    OUTPUT_FORMAT(elf32-littlearm)
    GROUP ( ../../lib/libc.so.6 ../../usr/lib/libc_nonshared.a  AS_NEEDED ( ../../lib/ld-linux-armhf.so.3 ) )
    

    This appears to allow me to link up this file, which is GREAT!!

    Only problem is the it now throws this error:

    /opt/poky/2.6.1/sysroots/x86_64-pokysdk-linux/usr/libexec/arm-poky-linux-gnueabi/gcc/arm-poky-linux-gnueabi/8.2.0/real-ld:-1: warning: libGLESv2.so.2, needed by /opt/poky/2.6.1/sysroots/cortexa7t2hf-neon-vfpv4-poky-linux-gnueabi/usr/lib//libQt5Gui.so, not found (try using -rpath or -rpath-link)
    

    with additional "underfined referance to 'glGenerateMipmap'"
    "underfined referance to 'glActiveTexture'"
    "underfined referance to 'glCompressedTeximage2D'"
    and
    "underfined referance to 'glCompressedTexSubimage2D'"

    The file it is looking for, is again within the sysroots directory, and so there is some sort if $PATH error occurring, but I cannot find out how this is happening, or where to fix this.
    The other interesting thing is why is this file link missing???, it has no connection with the wiringPi library, if I comment out the last 3 lines of the .pro below (and comment all the #includes <wiringPi.h> etc) this program cross complies and runs on the CM3+ fine.

    Here is my complete .pro file listing:

    QT += quick serialbus serialport sql concurrent
    CONFIG += c++11
    
    # The following define makes your compiler emit warnings if you use
    # any feature of Qt which as been marked deprecated (the exact warnings
    # depend on your compiler). Please consult the documentation of the
    # deprecated API in order to know how to port your code away from it.
    DEFINES += QT_DEPRECATED_WARNINGS
    
    # You can also make your code fail to compile if you use deprecated APIs.
    # In order to do so, uncomment the following line.
    # You can also select to disable deprecated APIs only up to a certain version of Qt.
    #DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000    # disables all the APIs deprecated before Qt 6.0.0
    
    SOURCES += \
        main.cpp \
        simplegpio.cpp \
        onewiretemp.cpp
    
    RESOURCES += qml.qrc
    
    # install
    target.path=/home/root/
    INSTALLS += target
    
    # Additional import path used to resolve QML modules in Qt Creator's code model
    QML_IMPORT_PATH =
    
    # Additional import path used to resolve QML modules just for Qt Quick Designer
    QML_DESIGNER_IMPORT_PATH =
    
    # Default rules for deployment.
    # qnx: target.path = /tmp/$${TARGET}/bin
    # else: unix:!android: target.path = /opt/$${TARGET}/bin
    # !isEmpty(target.path): INSTALLS += target
    
    HEADERS += \
        simplegpio.h \
        onewiretemp.h
    
    DISTFILES +=
    
    # These next three lines allow for the use of wiringPi
    INCLUDEPATH += /opt/poky/2.6.1/sysroots/cortexa7t2hf-neon-vfpv4-poky-linux-gnueabi/usr/include
    LIBS += -L"/opt/poky/2.6.1/sysroots/cortexa7t2hf-neon-vfpv4-poky-linux-gnueabi/usr/lib/"
    LIBS += -lwiringPi
    
    

    Any hope would be much appreciated.



  • Hi All, I have another update which is interesting.....

    So I thought I'd try running WiringPi "Blink" in a new QT console application to test if all the linking was working correctly.

    Put together this very quick program:

    #include <QCoreApplication>
    #include <wiringPi.h>
    
    int main(int argc, char *argv[])
    {
        QCoreApplication a(argc, argv);
        wiringPiSetup();
        pinMode(17,OUTPUT);
        pinMode(18,OUTPUT);
        for (;;) {
        digitalWrite(17,1); delay(500);
        digitalWrite(17,0); delay(500);
        }
    
    
        return a.exec();
    }
    

    It cross complied and ran on the CM3+ target with no problems. This got my hopes up, so I through Id do the same with both a basic Widget and QML application.

    Unfortunately, both of these gave the ,

     warning: libGLESv2.so.2, needed by /opt/poky/2.6.1/sysroots/cortexa7t2hf-neon-vfpv4-poky-linux-gnueabi/usr/lib//libQt5Gui.so, not found (try using -rpath or -rpath-link)
    

    So this got me looking for the use of -rpath or -rpath-link. which in turn pointed me to this webpage -rpath issues

    I'm trying to work this out but so far no luck, maybe this link will remind someone of a similar problem. Anyone else come across this problem??

    I wonder if I should move this to the raspberry pi section, I don't feel like I'm exciting anyone in this group. :-)

    Cheers............


Log in to reply