"undefined symbol: state" error while trying to build cpp extension with THCState

Hi,
Just trying to rebuild the cpp extension I previously built(previously with torch.utils.ffi which is deprecated since pytorch1.0).

But got the following error: “undefined symbol: state”.
Since in my cpp source code, I do use the statement “extern THCState *state;”, I guess the problem is there.
However, just google it does not solve my problem(only got a old link https://github.com/pytorch/extension-ffi/issues/14 and not fit in the pytorch1.0 problem)

Does anyone know what may cause such a problem, or any suggestions?

here is my setup.py, basically following the official document:

from setuptools import setup
from torch.utils.cpp_extension import BuildExtension, CUDAExtension
import glob, os

abs_path = os.path.dirname(os.path.realpath(__file__))

setup(
	name='scatterUtils',
	ext_modules=[
		CUDAExtension(
				name='scatterUtils',
				sources=['scatter_utils.cpp', 'scatter_cuda_kernel.cu'],
				extra_compile_args={'cxx': ['-g'],
									'nvcc': ['-O2']})
	],
	cmdclass={
		'build_ext': BuildExtension
	},
	include_dirs=[os.path.join(abs_path, 'include')],
	)
1 Like