Integrating Pylon into QT Application



  • Hi,

    I am trying to use Pylon to record video and display it in my QT GUI and am running into tons of errors.

    I am trying this on my laptop with windows 10 64bit installation.

    In my .pro file, I current have this for the pylon software:
    INCLUDEPATH += "C:\Program Files\Basler\pylon 5\Development\include"
    LIBS += -L"C:\Program Files\Basler\pylon 5\Development\lib\Win32\GCBase_MD_VC141_v3_1_Basler_pylon.lib"
    LIBS += -L"C:\Program Files\Basler\pylon 5\Development\lib\Win32 \GenApi_MD_VC141_v3_1_Basler_pylon.lib"
    LIBS += -L"C:\Program Files\Basler\pylon 5\Development\lib\Win32\PylonBase_v5_2.lib"
    LIBS += -L"C:\Program Files\Basler\pylon 5\Development\lib\Win32\PylonC.lib"
    LIBS += -L"C:\Program Files\Basler\pylon 5\Development\lib\Win32\PylonGUI_v5_2.lib"
    LIBS += -L"C:\Program Files\Basler\pylon 5\Development\lib\Win32\PylonUtility_v5_2.lib"

    In my mainwindow.cpp, I added:
    #include <GenICam.h>

    After adding that include line, my otherwise working GUI is now throwing 892 errors. I included a screenshot of the first 20 or so errors that I am having.

    I already attempted switching the "Win32" directory with the "x64" option just to test it out and it is still returning these errors.

    0_1553014378900_36100e13-0dc1-423f-8975-ec1ecc02b763-image.png

    Any help would be greatly appreciated.



  • @jgmills
    The errors actually seem to be in the Pylon include files rather than the Qt ones.
    I would pick the first error, #error Unknown shared library support in file GCLinkage.h, and look to see why that is being hit.
    You could set up a fresh project to compile with #include <GenICam.h> but no Qt headers/code and just see how that goes.
    It may be that how you are compiling in Qt is not acceptable for Pylon, e.g. C++17 or whatever.
    Do you have any evidence that Pylon compiles OK with what you are using? E.g. is it supposed to be OK with MinGW, or is it MSVC only?
    Do those .lib files look like MSVC, you look like you're MinGW, they are not going to mix? (You're not getting as far as linking, only compiling, but that might be a warning that header files are not going to be compatible too.)
    It looks like you're compiling 64 bit, and Pylon's libs look 64 bit, so that part looks OK to me.



  • @JonB

    Thanks for getting back to me. Sorry it took so long to respond.

    I tried doing everything in a new QT project and it still had around 50 errors instead of 900.

    Just from looking through the GCLinkage.h file, it looks like it can't determine if I am using a Linux, Apple, or Windows machine. So I assume it could be an issue with using MinGW and not MSVC.

    When I created the QT Project, I have both MinGW and MSVC kits enabled so I do not know how to go around this issue. I am running everything through QT Creator so I do not have Visual Studio installed.

    What would you recommend me doing to resolve this mix-up?



  • @jgmills
    I'm not an expert here --- I don't even use C++ with Qt! :)

    But I'm warning you now: if your Pylon is supplied pre-compiled in .lib files (MSVC) then you are not going to be able to link to those from source compiled with MinGW. You need to use a consistent set of either MSVC or MinGW for all the bits of a single project/executable. So first thing is you need to decide whether you want to be all MSVC or all MinGW. And by the sounds of the errors it might be that the Pylon only really wants to be compiled MSVC not MinGW?

    Others will have to tell you, but I believe you can use MSVC from Qt Creator, you just need to select that everywhere? I do not believe you have to have VS.



  • @JonB

    Ok thank you for helping me.

    I did find some .dll files that did match some of the .lib files that I was using such as:
    LIBS += "C:\Program Files\Basler\pylon 5\Runtime\Win32\GenApi_MD_VC141_v3_1_Basler_pylon.dll"

    Replacing those did not help though. I am going to keep messing around with it to see what is causing the "error Unknown shared library support" error and hope someone might be able to shine some more light on it.

    Thank you!



  • @jgmills
    I wouldn't expect you to get any errors compiling an empty project.

    You wrote earlier:

    When I created the QT Project, I have both MinGW and MSVC kits enabled

    Doesn't it work that you pick one or the other for a project? If you have both kits, how does it fare compiling under the other one from whatever you were using?

    P.S.
    Take a look at https://stackoverflow.com/questions/51394905/how-to-build-pylon-camera-using-mingw-compiler ? And even https://stackoverflow.com/questions/11793370/how-can-i-convert-a-vsts-lib-to-a-mingw-a

    Looks like a rabbit warren. Sounds to me like you'll have more luck with Pylon under Windows if you use MSVC rather than trying with MinGW?



  • @JonB

    I wouldn't expect you to get any errors compiling an empty project.

    Sorry, I meant I added the Pylon library includes and tried to #include <GenICam.h> from an empty project.

    You wrote earlier:

    When I created the QT Project, I have both MinGW and MSVC kits enabled

    Doesn't it work that you pick one or the other for a project? If you have both kits, how does it fare compiling under the other one from whatever you were using?

    I think this may be the issue. I just noticed I have been selecting both MSVC kits and MinGW kits but I do not have a way to compile MSVC so it just defaults to MinGW. I noticed that while trying to select just the MSVC kit, QT Creator later made me select the MinGW Kit. I am going to install a way to compile using MSVC, I assume installing Visual Studio will allow this?

    Thank you again for the help.


  • Lifetime Qt Champion

    Hi,

    You need either Visual Studio or now you can have only the build tools if you are not interested in VS itself.

    One other thing you should check is whether you have 32 or 64 bit versions of the Pylon libraries.



  • @SGaist

    I got Visual Studio and the required packages I believe.

    One other thing you should check is whether you have 32 or 64 bit versions of the Pylon libraries.

    When looking through the Development/lib part of pylon, it only lists Win32 or x64 for the Pylon libraries. I assumed x64 was not for Windows but could be wrong there.



  • @jgmills
    I too could be wrong, but I would have thought that x64 would apply to Windows 64-bit, e.g. https://www.baslerweb.com/en/sales-support/downloads/software-downloads/pylon-5-0-12-windows/

    Basler pylon 5 supports all current Windows versions up to Windows 10 (32 and 64-bit).


  • Lifetime Qt Champion

    There are several possible notations:

    • x86, Win32 are usually for 32bit
    • x86_64, amd64, x64, Win64 are usually for 64bit

    I write usually because from time to time you can find 64bit stuff under Win32 because reasons.

    In any case, I recommend to never assume anything when related to programming and SDK. Naming conventions can be misleading so it's always better to check everything provided.



  • @JonB @SGaist

    I believe you are both correct.

    I reinstalled QT to come with MSVC capabilities and created a project with the MSVC 2017 64-bit kit. I included all of the necessary packages for pylon and am no longer getting the old errors but I am now getting :-1: error: LNK1104: cannot open file 'GCBase_MDd_VC141_v3_1_Basler_pylon.lib' when I try to compile just an empty project with an #include <GenICam.h>



  • @jgmills
    OK, I suspect you are on better lines now that you are opting for MSVC rather than MinGW.

    GCBase_MDd_VC141_v3_1_Basler_pylon.lib

    This is a Pylon library. The MDd indicates you are compiling/linking for debug with the MSVC -MD (or /MD) option. That's probably OK, though I have a slight concern: I have never compiled with MSVC for 64-bit, which I think is what you have decided to do, it might be that flag would be for 32-bit. Keep an eye on that when you get further just in case it's an issue.

    You must now try to find that precise filename in the Pylon area, probably in some kind of libs folder. Go search!

    • If you find it, as I would expect you to, good! If not, bad :(

    • Assuming you do find it: you now need to tell you link phase to search the directory it is in for extra libraries. Possibly by having your LIBS variable add that directory to its directories. I don't know how you do that in Qt Creator/.pro file, but there will be a way. Have a look where Creator lets you specify stuff for your chosen compiler kit, there should be something there.



  • @JonB

    Sorry for taking so long to get back to you. Yes, now that I am compiling in MSVC things seem to be better, thank you for that.

    I changed the QT project to compile in Release mode rather than debug and that took care of the issue. That MDd file was not in my directory but the MD was.

    I am no longer getting these compile errors so I think I am ready to get going.

    Thank you again for all of your help!



  • @jgmills
    It did not occur to me that they would not have supplied you with the debug version of the library (you sure you downloaded everything they offered?). As you discovered, the d on the end of _MDd_ indicates a library compiled with -MD plus debug (something like -Od -Zi, IIRC). You'll have to keep an eye on what happens when you want to compile your own code with debug, which you're sure to want to do, yet link with Pylon compiled for release. I don't know, you may have problems at runtime where your stuff wants the C/C++ debug libraries/DLLs while Pylon wants the non-debug ones. I don't know whether Pylon gives you their sources so that you can compile those for debug too.



  • @JonB

    I downloaded straight from their site with the only Pylon option so I don't think anything was installed wrong. I will double check with the installer to see if any setting can be changed.

    I don't see how I can switch between release and debug though since I will get errors compiling on debug, I think I will just try to stay in release.

    Thank you