简体   繁体   English

检查 OpenCV 是否使用 C++ 代码中的 GTK 支持编译

[英]Check if OpenCV is compiled with GTK support from C++ code

My problem is the same as in: OpenCV GTK+2.x error我的问题与以下相同: OpenCV GTK+2.x 错误

I am facing this problem deploying my code in systems where OpenCV is available but has not been installed with GTK support.在 OpenCV 可用但尚未安装 GTK 支持的系统中部署我的代码时,我遇到了这个问题。 I have no control over OpenCV installation in these systems.我无法控制这些系统中的 OpenCV 安装。

How can I discriminate where OpenCV is compiled without GTK support from C++ code, possibly without relying on catching exceptions?如何在没有 GTK 支持的情况下从 C++ 代码中区分 OpenCV 的编译位置,可能不依赖于捕获异常? I would simply avoid calling imshow in these cases.在这些情况下,我会避免调用 imshow 。

you could check dependencies by executing ldd opencv-lib and parse the output using eg regex to check for some kind of gtk libs.您可以通过执行ldd opencv-lib来检查依赖关系,并使用例如正则表达式来解析输出以检查某种 gtk 库。

Or use this approach: linux/gcc: ldd functionality from inside a C/C++ program或使用此方法: linux/gcc: ldd 功能来自 C/C++ 程序内部

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM