Python calls C to generate so library and reports an error: undefined symbol

  After using C + + to implement some algorithm functions, there is an error when calling Python:

AttributeError: /..../libHessian4Nii.so: undefined symbol: callVesselSegNii

    According to Du Niang, it is because the function name will be renamed in the C + + compiled file (which is convenient to realize the overload function), so the function name cannot be found when calling the script.

The solution is to use   extern “C”   Just enclose the header file to be exposed. Examples are as follows:

extern "C"{

  int callVesselSegNii(char* oriNiiFile, char* maskNiiFile, char* save_path);
 
}

After recompilation, call the normal!!!!

Read More: