Library doesn't open
-
@aha_1980
I think this is the Compile Output you need:g++ -Wl,-subsystem,console -mthreads -o debug\ConnectBitScope.exe debug/main.o -LC:\BitScope32\Library\BitLib.lib debug/main.o: In function `main': C:\Users\adm-eep\Documents\ConnectBitScope\build-ConnectBitScope-Desktop_Qt_5_13_0_MinGW_64_bit-Debug/../ConnectBitScope/main.cpp:23: undefined reference to `BL_Open' collect2.exe: error: ld returned 1 exit status mingw32-make[1]: *** [Makefile.Debug:66: debug/ConnectBitScope.exe] Error 1 mingw32-make: *** [Makefile:38: debug] Error 2 mingw32-make[1]: Leaving directory 'C:/Users/adm-eep/Documents/ConnectBitScope/build-ConnectBitScope-Desktop_Qt_5_13_0_MinGW_64_bit-Debug'
I use the MSVC 11.0
I saw the example but i think this is for librarys with the ending .so I am no sure how to use this in my case
-
@alexfi said in Library doesn't open:
I use the MSVC 11.0
In that case, something is really weird set up - no wonder that it doesn't work.
Your compile output clearly shows the MinGW linker running.
Can you please show the screenshots of Tools > Options > Kits for Kits, Qt versions and compilers?
Regards
-
@alexfi said in Library doesn't open:
librarys with the ending .so
you may want to try with .lib in your case
-
@Pablo-J-Rogina
I tried it like this :g++ -o$$PWD/ $$PWD/BitLib.lib but i get the "extra characters after test expression" error
-
@manuja said in Library doesn't open:
LNK1104
This shows that you used the msvc linker before
BitLib.lib
This shows that the library was build with msvc
So if bitlib is a plain C library you can create a proper import lib with reimp & co (google is your friend) or you can try to link directly against the dll -> -lC:/BitScope64/Library/BitLib.dll - it should work with a recent MinGW version iirc.
If it's a c++ library than you have to recompile it with g++ to get a proper import lib (BitLib.a) -
@christian-ehrlicher
okay, if i under stand you right i have to reimport the lib, because it is written in c BitScope Librarys and this Bitscope example in C .I tried this:
LIBS += -lC:/BitScope64/Library/BitLib.dll - it
the direct link doesn't work if I use it like this because of the ending "- it".
is the reimport something i do in my actual project or is external work?
-
@alexfi said in Library doesn't open:
because of the ending "- it".
Where does this come from? Your library is named BitLib.dll ...
-
@christian-ehrlicher sorry my fault. I just didn't read the following sentence after your recommendation, but i also tried it without and it gave me back undefined reference. Now i try to find out how to reimport the lib.
-
@alexfi Just a note: the only Kit you have is one for MinGW not MSVC...
-
@jsulm thank you for your answer. Do I understand this right, that these basic settings should work?
-
I solved my problem with BitScope. Here a short overview of the setup:
First I just downloaded the 32bit library:
http://my.bitscope.com/download/?p=download
FileType: Drivers&Libraries:
bitscope-library_2.0.FE26B_i386.zip->run the .exe file and a folder is created, in my case in c:/programm files/bitscope.
I copied the folder to d:/bitscope, because I thought qt-creator has problems with the space in "programm files", it also works in c:.
Then I created a new QT project "QT Widgets Application"
For debugging, I use QT.5.13.1 MinGW 32-BitModified the .pro file with following:
code_text HEADERS += \ bitlib.h INCLUDEPATH +="D:\BitScope\Library" INCLUDEPATH +="D:\BitScope" LIBS += "D:\BitScope\Library\BitLib.lib"
I copied the "bitlib.h" file of the library folder in the project folder
and the "BitLib.dll" in the debug folder of my current project, where you find the .exe file after you build your project the first time.To use the library you just have to add in your .cpp file
code_text #include<bitlib.h> #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 5000 /* capture sample rate */ #define MY_SIZE 12270 /* number of samples to capture */ #define max_SIZE 12270 #define n_of_ms 2 Project::Project(QWidget *parent) : QMainWindow(parent), ui(new Ui::Project) { ui->setupUi(this); setUpGrafics(); /* * Open and select the first channel on the first device. */ printf("\nStarting: Attempting to open %d device%s...\n",MY_DEVICES,MY_DEVICES!=1?"s":""); QString sVar; sVar.sprintf("\nStarting: Attempting to open %d device%s...\n",MY_DEVICES,MY_DEVICES!=1?"s":""); if ( ! BL_Open(MY_PROBE_FILE,MY_DEVICE) ) { printf("Failed to find a devices.\n"); } if ( BL_Select(BL_SELECT_DEVICE,MY_DEVICE) != MY_DEVICE ) { printf("Failed to select device %d.\n",MY_DEVICE); } if ( BL_Select(BL_SELECT_CHANNEL,MY_CHANNEL) != MY_CHANNEL ) { printf("Failed to select channel %d.\n",MY_CHANNEL); } /* * Prepare to capture one channel... */ if ( BL_Mode(MY_MODE) != MY_MODE ) { printf("Failed to select mode %d.\n",MY_MODE); } 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 */ /* * Capture and acquire the data... */ printf(" Trace: %d samples @ %.0fHz = %fs\n",BL_Size(BL_ASK),BL_Rate(BL_ASK), BL_Time(BL_ASK)); if ( BL_Trace(BL_TRACE_FORCED,BL_SYNCHRONOUS) ) { /* capture data (without a trigger) */ int i, n = MY_SIZE; double d[MY_SIZE]; /* let's get 5 samples */ BL_Select(BL_SELECT_CHANNEL,MY_CHANNEL); /* optional if only one channel */ if ( BL_Acquire(n, d) == n ) { /* acquire (i.e. dump) the capture data */ printf("Acquired:"); for (i = 0; i < n; i++) //printf(" %f", d[i]); // printf("\n\n"); Data3.append(d[i+j*n_of_ms]); printf(" %f", Data3.value(i)); } } printf("Data acquisition complete. Dump Log...\n"); printf(BL_Log()); BL_Close(); /* call this to release library resources */ }
I don't know why, but I got troubles when i wanted to call the functions of BitLib.lib in the main.cpp
so I just called them in the project.cpp and it worked well.With the sample code of https://www.bitscope.com/software/library/guide/2.0/
after I changed in the code the dynamic array to an fixed value and "TRUE" to "true" and deleted the " goto exit," jumps
This example runs.Thanks everyone for your help, I hope this will help following BitScope QT users.
Have a nice Day! -
Hello,
i need your help again.
there is one functionality I need from BitScope which is not given in the BitLib, specific I want to switch an output of the BitScope Micro. I got the hint to use https://docs.bitscope.com/LYK5QKSL/#programming but I am not sure, if i can setup this with QT. Do you have any ideas, for that?kind regards
alex
-
@AlexFi please open your own post for this new topic. Thanks.