Issue With Generating C++ Wrapper File For Python Code Using SWIG

35 Views Asked by At

I have to use a C++ code in my Python Base Model. After my research, I came through SWIG, which creates C++ wrappers to integrate them into the Python code. My C++ code is extensive and I don't have time to convert it by using other options i.e., PyBind11, Cython etc.

So, after installing 'swig' in the CONDA Environment, I tried to create the wrapper file but failed to do so. I have given the detailed steps below which I tried and attached Screenshots for the errors I faced.

I executed the following steps which resulted into error:

Step - 1: Installed swig on my CONDA Environment by the command: pip install swig

Screenshot for the successful Installation of the SWIG:

enter image description here

Step - 2: After the installation, I navigated to the directory where my CPP file is placed which I need to convert into a wrapper file to make it usable in my Python code.

Step - 3: Then I tried the following command to convert the CPP code file into a wrapper file.

swig -python implicit_feature_encoding.cpp -o implicit_wrapper.cpp

It resulted into the error as displayed in the screenshot:

enter image description here

Note: At first, I tried it without creating a new wrapper file with name: 'implicit wrapper'. Later, I created the 'implicit_wrapper.cpp' file manually. However, the initial step is not being cleared.

I have also navigated through SWIG tutorials and came through the concept of creating Interface file. My C++ code is quite extensive with dependencies on three Header files, so if there is any other solution rather than creating an interface file, then suggest that too.

Thanks

0

There are 0 best solutions below