Home > Net >  Swig Error when using C functions in Kotlin - two different errors
Swig Error when using C functions in Kotlin - two different errors

Time:06-23

I am using the following command using swig:

swig -java -includeall -package onescream.onescream compute_feature_set.i

The interface file is:

/* compute_feature_set.i */
 %module compute_feature_set
%{
/* Includes the header in the wrapper code */
#include "compute_feature_set.h"
%}

/* Parse the header file to generate wrappers */
%include "compute_feature_set.h"

I get the following errors:

compute_feature_set.h:17: Error: Unable to find 'stddef.h'
compute_feature_set.h:18: Error: Unable to find 'stdlib.h'

If I try an alternative swig command list:

swig -java compute_feature_set.i
gcc -c compute_feature_set.c compute_feature_set_wrap.c -I/Users/fas/Library/Java/JavaVirtualMachines/openjdk-18.0.1.1/Contents/Home/include -I/Users/fas/Library/Java/JavaVirtualMachines/openjdk-18.0.1.1/Contents/Home/include/darwin
gcc -shared compute_feature_set.o compute_feature_set_wrap.o -o libcompute_feature_set.so

I get the following error:

Undefined symbols for architecture arm64:
  "_b_fft", referenced from:
      _compute_feature_set in compute_feature_set.o
  "_binary_expand_op", referenced from:
      _compute_feature_set in compute_feature_set.o
  "_eml_find", referenced from:
      _compute_feature_set in compute_feature_set.o
ld: symbol(s) not found for architecture arm64
clang: error: linker command failed with exit code 1 (use -v to see invocation)

I am not sure what else to do, any assistance here would be greatly appreciated.

CodePudding user response:

You don't usually want -includeall, since you are unlikely to want to wrap the endire stddef.h and stdlib.h library functions (and in general it wouldn't work anyway).

Use -I<dir> to include other include directories in the search path.

  • Related