Hi !
I am trying to make my custom C++ extension for pytorch.
Intro:
C++ file look like this:
#include <torch/torch.h>
#include <opencv2/cudaarithm.hpp>
#include <opencv2/cudaimgproc.hpp>

//CODE ...

cv::pyrDown(in, out, cv::Size(X, Y));

//CODE ...

setup.py look like this:
from setuptools import setup
from torch.utils.cpp_extension import CppExtension, BuildExtension

setup(name='lltm',
      ext_modules=[
          CppExtension(
              'gaussianpyramid',
              ['src/pyramid.cpp'],
              extra_compile_args=['-lopencv_calib3d', '-lopencv_contrib', '-lopencv_core', '-lopencv_features2d',
                                  '-lopencv_flann', '-lopencv_highgui', '-lopencv_imgproc', '-lopencv_legacy',
                                  '-lopencv_ml', '-lopencv_objdetect', '-lopencv_photo', '-lopencv_stitching',
                                  '-lopencv_superres', '-lopencv_ts', '-lopencv_video', '-lopencv_videostab'],

          )],
      cmdclass={'build_ext': BuildExtension},
      )

The problem:
After compilation, if in a python script I have:
import MY_LIB
It stop by an error: undefined symbol: _ZN2cv7pyrDownERKNS_11_InputArrayERKNS_12_OutputArrayERKNS_5Size_IiEEi
Info:
OpenCV library are in my LD_LIBRARY_PATH
ldconfig -N -v $(sed 's/:/ /g' <<< $LD_LIBRARY_PATH) | grep opencv find them
This symbol is inside the opencv library (I have check this with a grep on the library)
Another error (and I think it come from there, is than if I do a ldd my_lib.so (generated by the setup.py), I don’t have the opencv lib, only:
	linux-vdso.so.1 =>  (0x00007ffc46dc4000)
	libstdc++.so.6 => XXX (0x00007fbda60e6000)
	libm.so.6 => XXX (0x00007fbda5db3000)
	libgcc_s.so.1 => XXX (0x00007fbda5ba1000)
	libpthread.so.0 => XXX (0x00007fbda5985000)
	libc.so.6 => XXX (0x00007fbda55c1000)
	/lib64/ld-linux-x86-64.so.2 (0x00005573b895d000)

And no opencv library…