Library doesn't open



  • I am trying to link Bitscope library, http://www.bitscope.com/software/library/ to QtCreator 5.6. I followed the normal instructions of adding an external library and this code was produced in .pro
    win32:CONFIG(release, debug|release): LIBS += -L$$PWD/'C:/Program Files (x86)/BitScope/Library/' -lBitLib
    else:win32:CONFIG(debug, debug|release): LIBS += -L$$PWD/'C:/Program Files (x86)/BitScope/Library/' -lBitLibd
    else:unix: LIBS += -L$$PWD/'C:/Program Files (x86)/BitScope/Library/' -lBitLib

    INCLUDEPATH += $$PWD/'C:/Program Files (x86)/BitScope/Library'
    DEPENDPATH += $$PWD/'C:/Program Files (x86)/BitScope/Library'

    But when build produces an error
    :-1: error: LNK1104: cannot open file 'BitLibd.lib'

    Thanks in advance for a solution


  • Moderators

    Do you have BitLibd.lib in C:/Program Files (x86)/BitScope/Library?
    In general you should avoid using directories with blanks, this is a source for problems.



  • @jsulm Thank you very much for replying
    The Library has BitLib.lib.
    BitLibd.lib was created since I kept the default tick on in "Add 'd' suffix for debug version" in the 'add library' dialog. Even if I uncheck it and add the library:
    The code created in .pro is
    unix|win32: LIBS += -L$$PWD/'C:/Program Files (x86)/BitScope/Library/' -lBitLib

    INCLUDEPATH += $$PWD/'C:/Program Files (x86)/BitScope/Library'
    DEPENDPATH += $$PWD/'C:/Program Files (x86)/BitScope/Library'

    and the error remains as
    :-1: error: LNK1104: cannot open file 'BitLib.lib'

    I tried qmake -> build procedure but still the error remains.
    Even tried deleting '$$PWD' in paths as suggested in a similar thread but the problem remains.



  • @manuja I assume your development enviroment is Windows. If so, could it be possible you uninstall BitScope library from default installation folder (i.e. C:/Program Files (x86)/BitScope) and install it again under a path without spaces (i.e. C:\BitScope)?
    I've tried and I was able to build a simple Qt console application just for Windows and adding by hand these lines to the .pro file:
    INCLUDEPATH +=C:/BitScope/Library
    LIBS += -LC:/BitScope/Library -lBitLib



  • @Pablo-J.-Rogina Thanks for the reply.
    Yes I am working in Windows. I changed the installation folder to C:, reinstalled the library and added the lines you suggested. Then it created a number of errors as
    mainwindow.obj:-1: error: LNK2019: unresolved external symbol BL_Count referenced in function "public: _cdecl MainWindow::MainWindow(class QWidget *)" (??0MainWindow@@QEAA@PEAVQWidget@@@Z)
    And the error appears for all the BL
    * functions.

    When I go with the .pro code created automatically when adding the library the earlier error remains. That is:
    :-1: error: LNK1104: cannot open file 'BitLib.lib'
    :(



  • I changed the installation folder to C:
    Could you state the full path of your installation folder?
    And could you post the contents of your .pro file?



  • @Pablo-J.-Rogina
    unix|win32: LIBS += -L$$PWD/C:/BitScope/Library/ -lBitLib

    INCLUDEPATH += $$PWD/C:/BitScope/Library
    DEPENDPATH += $$PWD/C:/BitScope/Library

    This is the .pro code that is generated automatically.

    C:\BitScope\Library - The full path of library

    Thanks



  • It looks like you're not following my recommendations :-)
    Forget about the automatically created .pro file, change it by hand. Please compare the two lines I posted with what you have now...



  • @Pablo-J.-Rogina I'm sorry but I did try the lines you suggested as I mentioned in my first reply to you. But it created 11 errors for each of the BL_ functions in my mainwindow.cpp.
    Maybe the error is now with the functions I used.
    I directly copied from the sample code on the Bitscope Library manual, these lines:
    BL_Intro(BL_ZERO); /* optional, default BL_ZERO /
    BL_Delay(BL_ZERO); /
    optional, default BL_ZERO /
    BL_Rate(MY_RATE); /
    optional, default BL_MAX_RATE /
    BL_Size(MY_SIZE); /
    optional, default BL_MAX_SIZE /
    BL_Select(BL_SELECT_CHANNEL,MY_CHANNEL); /
    choose the channel /
    BL_Trigger(BL_ZERO,BL_TRIG_RISE); /
    optional when untriggered /
    BL_Select(BL_SELECT_SOURCE,BL_SOURCE_POD); /
    use the POD input /
    BL_Range(BL_Count(BL_COUNT_RANGE)); /
    maximum range /
    BL_Offset(BL_ZERO); /
    optional, default 0 /
    BL_Enable(TRUE); /
    at least one channel must be initialised */

    Very much appreciate your support :)

    I'll add the full code just in case:
    #include "mainwindow.h"
    #include "ui_mainwindow.h"
    #include "limits.h"
    #include "bitlib.h"

    int x1=0, yl=0, x2=0, y2=0, x3=0, y3=0, x4=0, y4=0;
    #define MY_DEVICES 1 /* open one device only /
    #define MY_PROBE_FILE "" /
    default probe file if unspecified */

    #define MY_DEVICE 0
    #define MY_CHANNEL 0
    #define MY_MODE BL_MODE_FAST
    #define MY_RATE 1000000 /* capture sample rate /
    #define MY_SIZE 4 /
    number of samples to capture */

    MainWindow::MainWindow(QWidget parent) :
    QMainWindow(parent),
    ui(new Ui::MainWindow)
    {
    ui->setupUi(this);
    BL_Intro(BL_ZERO); /
    optional, default BL_ZERO /
    BL_Delay(BL_ZERO); /
    optional, default BL_ZERO /
    BL_Rate(MY_RATE); /
    optional, default BL_MAX_RATE /
    BL_Size(MY_SIZE); /
    optional, default BL_MAX_SIZE /
    BL_Select(BL_SELECT_CHANNEL,MY_CHANNEL); /
    choose the channel /
    BL_Trigger(BL_ZERO,BL_TRIG_RISE); /
    optional when untriggered /
    BL_Select(BL_SELECT_SOURCE,BL_SOURCE_POD); /
    use the POD input /
    BL_Range(BL_Count(BL_COUNT_RANGE)); /
    maximum range /
    BL_Offset(BL_ZERO); /
    optional, default 0 /
    BL_Enable(TRUE); /
    at least one channel must be initialised */
    }

    MainWindow::~MainWindow()
    {
    delete ui;
    }

    void MainWindow::on_btnCharge1_clicked()
    {
    x1 = ui->txtCharge1->text().toInt();
    }

    void MainWindow::on_btnCharge2_clicked()
    {
    x2 = ui->txtCharge2->text().toInt();
    }

    void MainWindow::on_btnCharge3_clicked()
    {
    x3 = ui->txtCharge3->text().toInt();
    }

    void MainWindow::on_btnCharge4_clicked()
    {
    x4 = ui->txtCharge4->text().toInt();
    }

    void MainWindow::on_btnCalibrate_clicked()
    {

    QVector<double> x(4),y(4);
    x[0]=x1;
    y[0]=yl;
    x[1]=x2;
    y[1]=y2;
    x[2]=x3;
    y[2]=y3;
    x[3]=x4;
    y[3]=y4;
    ui->Plot->addGraph();
    ui->Plot->graph(0)->setData(x, y);
    // give the axes some labels:
    ui->Plot->xAxis->setLabel("x");
    ui->Plot->yAxis->setLabel("y");
    // set axes ranges, so we see all data:
    ui->Plot->xAxis->setRange(0, 100);
    //ui->Plot->yAxis->setRange(0, 1);
    ui->Plot->replot();
    

    }


  • Lifetime Qt Champion

    Hi and welcome to devnet,

    Did you check that both Qt and BitScope are built for the same architecture ?



  • @manuja I've just created a basic Qt GUI application, I hope you can grab code snippets from Bitbucket (sorry no time for a full Git repository).

    The application just displays a main window, nothing fancy, but by doing that most of the Bitscope functions you posted previously are called from QMainWindow constructor, so that proves Qt was able to build and run the application.

    As @SGaist mentioned please pay attention to what Bitscope version you're using (I mistakenly used x64 version initially, reinstalling i386 made the way with my environment: Win 7, Qt 4.7.4 and MinGW 32 bit)



  • @Pablo-J.-Rogina Thank you very much!!!
    I'll try this. I actually tried the same library functions in a C++ console application on Codeblocks and they worked fine. I'll try with your code. Thanks again :-)


Log in to reply
 

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