Integrating Pylon into QT Application
-
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-aLooks 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?
-
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.
-
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.
-
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 thatx64
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).
-
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.
-
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.
-
-
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 theMD
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, thed
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. -
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
-
@jgmills Your problem is that you are importing some Pylon headers in the wrong order/missing some include.
Basler suggest importing first the#include <pylon/PylonIncludes.h>
and after all the others needed in your headers file.
Checking the latter include you can find a comment:// PylonPlatform.h must be included before including any GenICam/GenApi header files, // to ensure that the GENICAM_COMPILER_STR macro used by GenICam/GenApi is set properly #include <pylon/Platform.h> #include <pylon/PylonLinkage.h>
That macro next enables the definition of
GENICAM_USER_ALWAYS_LINK_RELEASE
. This definition tells the compiler to link the library with theMD
specification also in debug mode.
Concluding, to be able to work in debug mode you can choose between:- In your headers that need some pylon include, add as first the
#include <pylon/PylonIncludes.h>
- If you want to avoid all the inclusion made by the latter, in your headers that need some pylon include, add as first the
#include <pylon/Platform.h>
and the#include <pylon/PylonLinkage.h>
- In your headers that need some pylon include, add as first the