i want to use pybind11 to create .so , my code contains this 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/includespkg-config --cflags gstreamer-1.0,opencv
-L/home/xxx/deepstream/deepstream-4.0/lib/ -lnvbufsurface -lcudart -lnvdsgst_meta -lnvds_meta -lnvdsgst_helperpkg-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/includespkg-config --libs gstreamer-1.0
python3 -m pybind11 --includes
example.cpp -o examplepython3-config --extension-suffix
and i import example in python3 i get undefined symbol: NvBufSurfaceSyncForDevice Please help me
All those linker flags should come after the cpp that needs them. 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