尝试导入 pybind opencv 模块时出现 libgtk 错误

libgtk error when trying to import pybind opencv module

我正在尝试用 OpenCv 和 Pybind 编译一些 C++ 代码 header: https://github.com/patrikhuber/eos/blob/v0.12.2/python/pybind11_opencv.hpp

这以前对我有用,所以我认为 header 文件不是问题所在。

我可以毫无问题地编译代码,但是当我尝试将创建的文件导入 Python 时,出现以下错误:

导入错误:/usr/lib/libgtk-3.so.0:未定义符号:g_mount_operation_set_is_tcrypt_hidden_volume

这是 C++ 代码:

#include <opencv2/imgproc.hpp>
#include <opencv2/highgui.hpp>

#include <pybind11/pybind11.h>
#include "pybind11_opencv.hpp"

using namespace std;

namespace py = pybind11;

cv::Mat func(cv::Mat Image1,cv::Mat Image2)
{
    return Image1;
}


PYBIND11_MODULE(pybind_module, m) 
{
    m.doc() = "Text";
    m.def("func", &func, "Function",
    py::arg("Image1"),
    py::arg("Image2"));
}


我猜这是我的设置 (arch linux) 的问题,因为我之前有过类似的工作,但即使是这个最小的例子也没有工作。

我能够使用以下编译器设置自行解决问题。

c++ -msse4 -O3 -Wall -shared -std=c++11 -fPIC -lopencv_imgcodecs `python3 -m pybind11 --includes` main.cpp -o executable`python3-config --extension-suffix` /usr/local/include/ -L/usr/local/lib/ -march=native

估计是之前的编译有误