how to link the object file to a Qt



  • Hi,

    I wrote one simple code in terminal
    vi test.c
    which displays "Hi"

    compiled that test.c file with the help of cross compiler,"arm-linux-gnueabihf-gcc" and generated a object file.

    next I copied that object file into my beagleboneboard,using

    scp test debian@192.168.7.2:/test

    now I want to link this object file which is present in beagleboneboard into Qt,

    is it possible to link this object file to Qt? if yes,
    then please suggest me how to link ,what are the steps to link that object file in to Qt?


  • Lifetime Qt Champion

    Hi
    In your Qt project file on the beagleboneboard, add
    LIBS += THEFILE.o
    and make sure that the .o file is in the project folder.

    This assumes that its the same compiler on the board as the one
    that produced the .o file.
    Wildly variation in compiler versions might prevent it from working.



  • Hi,

    "In your Qt project file on the beagleboneboard, add
    LIBS += THEFILE.o"

    It means I have to add that LIBS +=file.o to my beagleboard test file(executable file)?

    0_1568868010339_BBB.png

    0_1568868038177_exe (1).png


  • Lifetime Qt Champion

    Hi
    you must add it to the project on the board so you can compile the .-o into your new exe file.
    if you try to like add an o file to binary exe, that wont work.



  • Sorry,

    But I am not getting this
    "you must add it to the project on the board"(in board I have only one executable file,that is test)

    I need to add it on my qt project file in my system?


  • Lifetime Qt Champion

    @asha
    Hi
    You need need to add it to the .pro file that produces the Qt application.
    So it can be linked into the new exe file.

    You can not added to an already compiled app.

    So you need to add the .o to the project file for the app, where you want to include the .o file.



  • @mrjj

    Hi,

    I am running the application on qt,but not getting the output on qt creator app,

    the result i am getting on vnc platform,via command prompt..

    so I created .pro file in command prompt,and linked the object file(c++ object file),while executing this object file getting the result in command prompt ,not in vnc platform...

    so my question is, is it possible to link the cpp files to qt projects? if yes, how?

    the cpp file is:

    #include <iostream>
    using namespace std;
    int main()
    {
    cout<<"Hello World";

    return 0;
    }


  • Lifetime Qt Champion

    @Asha
    Hi
    You can just include the wanted .cpp in the .pro file or
    make file or what you use to compile. You can also link it into the porject as an .o file. However, if you have a main in the new .cpp that wont work as
    there already is a main for the qt app.

    Im not sure what you mean by
    "while executing this object file getting the result in command prompt ,not in vnc platform.."


Log in to reply