0

I use the following code to from here in the setup.py to make a python wrapper of a c++ class:

## ! DO NOT MANUALLY INVOKE THIS setup.py, USE CATKIN INSTEAD
from distutils.core import setup
from catkin_pkg.python_setup import generate_distutils_setup

setup_args = generate_distutils_setup(
    packages=['hw_interface_pkg'],
    package_dir={'': 'src'},
    requires=['std_msgs', 'rospy'],
)
setup(**setup_args)

the error I get is:

/src/cython/hw_interface.c:482:
/include/remote_hw.h:6:10: fatal error: array: No such file or directory
 #include <array>
          ^~~~~~~

which is the very first include in the header. Following this thread, this thread, and this thread, the main solution seems to be adding language="c++" in the arguments. However, this did not solve the problem for me and the code from above is also rather different from the one used in those threads. (it uses "generate_distutils_setup" instead of "cythonize" or "Extension").

In addition other than the standard c++ includes like #include <array>, there are also other ones which I'm not sure if the setup will find them. Can someone suggest a possible solution for this? could this issue be actually originating from the CMakelists.txt details?

Alejandro
  • 879
  • 11
  • 27

1 Answers1

0

The solution was adding the "set_source_files_properties" like the following in the child CMakeLists.txt.

... 
set_source_files_properties(hw_interface.pyx PROPERTIES CYTHON_IS_CXX TRUE)
cython_add_module(hw_interface hw_interface.pyx ../fibonacci.cpp)
...
Alejandro
  • 879
  • 11
  • 27