1

I'm currently working on a GUI developped using Qt Creator 4.8.1 and Qt 5.11.1 compiled with MinGW 32bit. The app will control different components such as camera and sensors. I'm having troubles with the imaging part of the project. We bought a camera from FLIR that comes with a SDK: Spinnaker.

What I want to use the camera in order to get images that I'll process using OpenCV. I've installed OpenCV and it's working. The problem comes from the supplier's SDK. In order to use it, I load the library in the .pro file

> INCLUDEPATH += "$$PWD\lib\Spinnaker\include"
> 
> win32:CONFIG(release, debug|release): LIBS +=
> -L$$PWD/'lib/Spinnaker/lib/vs2015/' -lSpinnaker_v140 else:win32:CONFIG(debug, debug|release): LIBS +=
> -L$$PWD/'lib/Spinnaker/lib/vs2015/' -lSpinnaker_v140 else:unix: LIBS += -L$$PWD/'lib/Spinnaker/lib/vs2015/' -lSpinnaker_v140
> 
> INCLUDEPATH += $$PWD/'lib/Spinnaker/lib/vs2015' DEPENDPATH +=
> $$PWD/'lib/Spinnaker/lib/vs2015'
> 
> win32:CONFIG(release, debug|release): LIBS +=
> -L$$PWD/'lib/Spinnaker/lib/vs2015/' -lSpinnakerGUI_WPF_v140 else:win32:CONFIG(debug, debug|release): LIBS +=
> -L$$PWD/'lib/Spinnaker/lib/vs2015/' -lSpinnakerGUI_WPF_v140 else:unix: LIBS += -L$$PWD/'lib/Spinnaker/lib/vs2015/' -lSpinnakerGUI_WPF_v140
> 
> INCLUDEPATH += $$PWD/'lib/Spinnaker/lib/vs2015' DEPENDPATH +=
> $$PWD/'lib/Spinnaker/lib/vs2015'

Then, I load the specific .h files that I need to use the library. That's where everything start to mess: when compiling, an error occurs from one of the .h files of the library. This error consist in an "Unknown Platform":

#if defined (_MSC_VER)
#   if defined (_WIN64)
#       define PLATFORM_NAME "Win64_x64"
#   else
#       define PLATFORM_NAME "Win32_i86"
#   endif
#elif defined (__GNUC__)
#   define GENICAM_GCC_VERSION (__GNUC__ * 10000 + __GNUC_MINOR__ * 100 + __GNUC_PATCHLEVEL__)
#   if defined (__LP64__)
#      if defined (__linux__)
#       define PLATFORM_NAME "Linux64_x64"
#      elif defined (__APPLE__)
#       define PLATFORM_NAME "Maci64_x64"
#      else
#       error Unknown Platform
#      endif
#   else
#      if defined (__linux__)
#       define PLATFORM_NAME "Linux32_i86"
#      elif defined (__APPLE__)
#       define PLATFORM_NAME "Maci64_x64"
#      elif defined (VXWORKS)
#       define PLATFORM_NAME "VxWorks_PPC"
#      else
#       error Unknown Platform
#      endif
#   endif
#else
#   error Unknown Platform
#endif

This error occurs because _MSC_VER isn't defined. This variable is supposed to be declared depending on the version of Microsoft Visual C++ version. For exemple, _MSC_VER = 1900 for MSVC++ 14.0.

I can't get pass this error and I added the Kit Desktop QT 5.9.6 MSVC2015 32bit to my project with the compiler Microsoft Visual C++ Compiler 14.0 (amd64_x86) but when I use it, Qt is no longer reconised by the IDE and neither is OpenCV.

I guess the problem comes from the fact that I try to use libraries compiled with 2 different compiler in the same project. Is it possible do to so? Do I need to recompile the Spinnaker SDK in order to suit my project? Thanks!

1 Answers1

3

"How can I use a library compiled with MSVC 14.0 in the Qt framework compiled with MinGW 32?" - You probably cannot.

C++ does not have a stable vendor neutral ABI. Meaning; everything (usually) has to be compiled with the exact same compiler in order to be successfully linked together (or work correctly at run time)

Even things compiled with different versions of the same compiler may be incompatible.

There are exceptions, but the general rule is: Build everything you link with the exact same compiler.

Jesper Juhl
  • 30,449
  • 3
  • 47
  • 70
  • What's about LoadLibrary + GetProcAddress + C API? – Nuzhny Feb 26 '19 at 19:37
  • That's working: I use QLibrary to load .dll libraries and then use .resolve() to access the library's functions. It's working without compiler problems. But I don't know if the Spinnaker library has a C API. I'll investigate. – DrPepitozer Feb 27 '19 at 10:07
  • I got confused... I'm the one supposed to build the C API. I've looked into the files and that could be viable solution! Thanks Nuzhny! I should've though about this earlier, it's a bit dirtier but at least, it'll work. – DrPepitozer Feb 27 '19 at 11:15