2

My problem is the same as in: OpenCV GTK+2.x error

I am facing this problem deploying my code in systems where OpenCV is available but has not been installed with GTK support. I have no control over OpenCV installation in these systems.

How can I discriminate where OpenCV is compiled without GTK support from C++ code, possibly without relying on catching exceptions? I would simply avoid calling imshow in these cases.

Gianni
  • 458
  • 5
  • 17
  • 2
    something like: `#if defined (HAVE_GTK)` should work. You can check build information also with [getBuildInformation](https://www.learnopencv.com/get-opencv-build-information-getbuildinformation/) – Miki Aug 29 '19 at 09:39

1 Answers1

2

you could check dependencies by executing ldd opencv-lib and parse the output using e.g. regex to check for some kind of gtk libs.

Or use this approach: linux/gcc: ldd functionality from inside a C/C++ program

setenv("LD_TRACE_LOADED_OBJECTS", "1", 1); FILE *ldd = popen("/lib/libz.so");

Marc Stroebel
  • 2,295
  • 1
  • 12
  • 21