使用pybind11 cmd的未定义符号

2024-10-04 11:24:56 发布

您现在位置:Python中文网/ 问答频道 /正文

我想使用pybind11来创建。因此,我的代码包含这个头

`#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.0python3 -m pybind11 --includes example.cpp -o examplepython3-config --extension-suffix

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


Tags: confighomeincludeexamplelibpkgmetapython3
1条回答
网友
1楼 · 发布于 2024-10-04 11:24:56

所有这些链接器标志都应该位于需要它们的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 

相关问题 更多 >