Static library problem...


  • Banned

    I am linking an external static library within my application and calling one function. The function is being called and doing it's job, but after the function is finished, my main application is returned. May be the main application is crashed. Below the point where I called the library function nothing is being executed. Please check the code snippet below.

    [code]

    //I have included the static library header file in the main application...
    #include "upgrade_model.h"
    #include <string>
    using namespace std;
    int main(int argc, char **argv)
    {
    QApplication app(argc,argv);
    qDebug() << "Before calling the lib function" << "\n";
    string newModel;
    char *model="data/abjf_GPt2.model";
    bool upgraded = upgrade_model(model,newModel);
    qDebug() << "After calling the lib function" << "\n"; //This line is not printed...main program returned or crashed. but the lib function is doing it's job
    return app.exec();
    }
    [/code]

    //upgrade_model.h file is like below

    [code]
    #ifndef UPGRADE_MODEL_H
    #define UPGRADE_MODEL_H

    #include <string.h>
    #include <string>

    using namespace std;
    bool upgrade_model(char * modelFile,string& newModel);
    #endif
    [/code]

    When I am building the application I am linking the library as I mentioned that in the .pro file.
    [code]
    LIBS += -LconverterFolder -lconverter //lib file name is 'libconverter.a'
    [/code]

    Why my main application is being crashed or returned, any help would be highly appreciated. thanks Sujan



  • There could be various reasons.

    <code>char * modelFile</code> is non-const; probably <code>upgrade_model()</code> modifies it, which is only allowed to a limited extent.

    Maybe your static library needs some initialization before <code>upgrade_model()</code> can be used.

    Have you already run your application in the debugger?


  • Banned

    yes I ran in debugger. After the function called it returned exited with code 1.


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.