简体   繁体   English

使用 pybind11 cmd 的未定义符号

[英]undefined symbol using pybind11 cmd

i want to use pybind11 to create.so, my code contains this header我想使用 pybind11 创建.so,我的代码包含这个 header

`#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"`

when i use:当我使用:

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 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_pgst pkg-config --libs gstreamer-1.0,opencv example.cpp -o example.so

or i use:或者我使用:

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 example python3-config --extension-suffix 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 example python3-config --extension-suffix

and i import example in python3 i get undefined symbol: NvBufSurfaceSyncForDevice Please help me我在 python3 中导入示例我得到未定义的符号:NvBufSurfaceSyncForDevice 请帮助我

All those linker flags should come after the cpp that needs them.所有这些 linker 标志都应该在需要它们的 cpp之后 I separated your code into different lines for readability.为了便于阅读,我将您的代码分成不同的行。

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 

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

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