【问题标题】:undefined symbol using pybind11 cmd使用 pybind11 cmd 的未定义符号
【发布时间】:2020-08-12 00:10:54
【问题描述】:

我想使用 pybind11 创建 .so ,我的代码包含这个头文件

`#include <pybind11/pybind11.h>
#include <gst/gst.h>
#include <glib.h>
#include <stdio.h>
#include <math.h>
#include <string.h>
#include <sys/time.h>
#include "nvbufsurface.h"`

当我使用时:

c++ -O3 -Wall -shared -std=c++11 -fPIC python3-config --cflags --ldflags -I/usr/local/lib/python3.6/dist-packages/pybind11/include -I/home/xxx/deepstream_sdk_v4 .0.2_x86_64/sources/includes pkg-config --cflags gstreamer-1.0,opencv -L/home/xxx/deepstream/deepstream-4.0/lib/ -lnvbufsurface -lcudart -lnvdsgst_meta -lnvds_meta -lnvdsgst_helper pkg-config --libs gstreamer-1.0,opencv example.cpp -o example.so

或者我使用:

c++ -O3 -Wall -shared -std=c++11 -fPIC pkg-config --cflags gstreamer-1.0 -L/home/xxx/deepstream/deepstream-4.0/lib -lnvbufsurface -lnvdsgst_meta -lnvds_meta -lnvdsgst_helper -lm -I/home /xxx/deepstream_sdk_v4.0.2_x86_64/sources/includes pkg-config --libs gstreamer-1.0 python3 -m pybind11 --includes example.cpp -o examplepython3-config --extension-suffix

我在 python3 中导入示例我得到未定义的符号:NvBufSurfaceSyncForDevice 请帮帮我

【问题讨论】:

    标签: python c++ python-3.x pybind11 pybinding


    【解决方案1】:

    所有这些链接器标志都应该出现在需要它们的 cpp 之后。为了便于阅读,我将您的代码分成不同的行。

    c++ -O3 -Wall -shared -std=c++11 -fPIC  \
    `pkg-config --cflags gstreamer-1.0` \
    -I/home/xxx/deepstream_sdk_v4.0.2_x86_64/sources/includes \
    `python3 -m pybind11 --includes` \
    example.cpp -o example`python3-config --extension-suffix` \
    `pkg-config --libs gstreamer-1.0` \
    -L/home/xxx/deepstream/deepstream-4.0/lib -lnvbufsurface -lnvdsgst_meta \
    -lnvds_meta -lnvdsgst_helper \
    -lm 
    

    【讨论】:

      猜你喜欢
      • 2022-06-22
      • 1970-01-01
      • 2017-07-05
      • 1970-01-01
      • 1970-01-01
      • 2012-11-07
      • 2017-03-10
      • 2018-12-28
      • 2015-05-01
      相关资源
      最近更新 更多