Pylon in Qt compilation issues
I have a project where I'm trying to get my Basler cameras to work in Qt. Qt's own QCamera does not recognise these cameras. Basler has their own Pylon module, but that one has been absolutely terrible to get working.
The problem is as follows:
I would prefer to use MinGW, but Basler's Pylon module does not support this. I've tried messing around with other things, even tried building OpenCV from source to be compatible with MinGW and get it to work, but I haven't had any luck. If anyone knows how to skip any MSVC nonsense, that would be the best solution.
I've also tried downloading Visual Studio to get a compiler compatible with Pylon. The problem with that is, Microsoft broke that library in VS2019 when they updated some of their macro expansion stuff. Not even the example files included in Pylon work from Visual Studio alone, even without Qt.
I then tried downloading the compiler for VS2017 (MSVC v141) through my copy of Visual Studio Community 2019, but Qt doesn't seem to recognise that compiler and I couldn't get it to work.
I then tried uninstalling VS entirely and reinstalling it with only MSVC v141, but Qt now doesn't recognise any MSVC compiler at all.
It seems to me that Qt doesn't play nice with VS2019 in the first place, but figuring out how to get a working copy of VS2017 has been quite the challenge. Microsoft seems to want you to pay in order to get an actual copy of VS2017, which I would prefer not to do, but just the compiler from the newer version doesn't work either. Any help would be greatly appreciated.
Sample of errors I get trying to compile:
Relevant parts of .pro file:
INCLUDEPATH += "C:\Basler\pylon6\Development\include" LIBS += "C:/Basler/pylon6/Development/lib/x64/GCBase_MD_VC141_v3_1_Basler_pylon.lib" LIBS +="C:/Basler/pylon6/Development/lib/x64/GenApi_MD_VC141_v3_1_Basler_pylon.lib" LIBS +="C:/Basler/pylon6/Development/lib/x64/PylonBase_v6_0.lib" LIBS +="C:/Basler/pylon6/Development/lib/x64/PylonC.lib" LIBS +="C:/Basler/pylon6/Development/lib/x64/PylonGUI_v6_0.lib" LIBS +="C:/Basler/pylon6/Development/lib/x64/PylonUtility_v6_0.lib"
Microsoft seems to want you to pay in order to get an actual copy of VS2017
Community edition is enough (even build tools would be enough). Did you select C++ support when installing VS2017?
@jsulm Yes, I did. This is what I have selected for my VSC2019 installation:
And this is what my compilers page looks like:
Qt complains about the ABI not matching, which is fair enough since it expects the 2017 version, but it doesn't seem to detect it.
@jsulm Apologies, I misread your response.
You're right, you can get VSC2017 for free from Microsoft, I just assumed I would have to pay for it because it said I needed a license. My mistake.
I have installed VSC2017 successfully and it now detects the compiler properly, along with not throwing a bunch of syntax errors on compilation. That's good. It compiles successfully if I don't try to include any of the libraries but only link them in the project file. However, if I do, I get a couple of errors.
The debug build produces the following:
:-1: error: LNK1104: cannot open file 'GCBase_MDd_VC141_v3_1_Basler_pylon.lib'
Which is weird, since I specifically link to that library, but whatever, if I switch to release build, I get the following error:
:-1: error: LNK1104: cannot open file 'PylonUtility_MD_VC100.lib'
That one's a little more understandable, since I don't actually link to that library, but that file is not included in the lib folder in the Pylon SDK. I tried googling it, but I couldn't really find anything relevant on it.
This has been a wild goosechase and a half, but I finally got at least the sample projects to run under Visual Studio 2010, which is apparently the version it expects, but I don't know how to get that working with new Qt, since the Visual C++ 2010 compiler can't compile Qt 5.13.
There might be some trickery with using the older build tools with a new compiler or something, but honestly, this is moving pretty firmly outside my current realm of understanding. Any help on how to proceed would be much appreciated.
@hodahle My guess is that the libs you want to use were built using MSVC2010 which is not compatible with MSVC2017.
@jsulm You can build it in newer version of Visual Studio as long as you have the old build tools. Seems it is dependent on MSVC2010, which is a disappointment to put it lightly.
Not sure about using it with Qt, though. Would downloading an older version of Qt compatible with MSVC2010 be the best way of going about it? Or should I maybe try to see if I can get some other software working with it instead? QCamera doesn't seem to function with those types of cameras, at least not with the
QCameraInfo::availableCameras()method, which only recognises my webcam. I'm at a bit of a loss here.
Would downloading an older version of Qt compatible with MSVC2010 be the best way of going about it?
If you want to use Pylon and it only supports MSVC2010 then yes.
Side note for posterity, but I think I found a way to go about it which works better for me and doesn't involve messing around with MSVC.
For whatever reason, downloading the full Pylon SDK package with the viewer and everything doesn't work very well for me and doesn't let the cameras be recognised as such by my device.
However, if I use only a runtime (I used v5.2, but you could probably use a different one too), it works and gets recognised. QCamera now also recognises the camera, though it fails to set proper viewfinder settings and therefore doesn't work. It also finds 4 cameras instead of just one, which I think is a quirk of the driver or something, since OpenCV does the same thing. I would prefer to do everything with Qt and not be dependent on any external framework, so if there's any pointers on how to set proper viewfinder settings that would be much appreciated, but for now this is fine.
What works and does recognise the camera while reading properly from the camera is OpenCV. In order to be used with MinGW, it has to be made from source with make, but I've managed to make it work on my machine. I followed this guide on the subject, and it worked for me after restarting.
Anyway, I finally have something I can work on again, and I'll consider this question solved. Thanks for the help.
rosmar last edited by
@hodahle I have the same issue. My development environment is Qt Version 5.15.0. My application is written in C++ and will be compiled in Qt creator using MinGW/gcc compiler. I installed pylon 6.1.1 Camera Software Suite Windows in developer mode. I want to integrate it with our development environment to see if our application will include the libraries and successfully build and run. I don't have the camera yet but I think that it should be possible to get to this point where the application will successfully build and run with few calls to simple APIs.
I'm stuck. How did you get it working by using Runtime package instead of complete SDK Package (pylon X.x.x Camera Software Suite Windows)? Also can you please provide more information and if possible, can you please attach a screenshot of your .pro file?
VikramJ last edited by
@hodahle : Request you to share your .pro snippet as how you went about using runtime Pylon dlls in your mingw QT based code. It will be great as I am stuck in exact same issue