I am using RHEL 6 and trying to compile some code using SWIG.
The SWIG file is named mySwig.i and looks like
%module base_module
%{
#include "base.h"
%}
%include "base.h"
The mySwig.i file is kept in a folder named foo. The folder foo also has other .h, .c and .cxx files.
The command I use is
gcc -fpic -c foo/*
The output is:
foo/mySwig.i:1 error: expected identifier or '(' before '%' token
foo/mySwig.i:3 error: stray '#' in program
foo/mySwig.i:5 error: expected identifier or '(' before '%' token
Does anyone have any ideas how to resolve these errors?
gcc -fpic -c foo/*will match all files in the directory foo/. You only want to match C files most likely. You can do what withgcc -fpic -c foo/*.cif you really want.Personally I’d recommend using something like CMake or Autotools, or even just a Makefile to build your project rather than calling cc directly.