So, I am just trying to get the simple example working. But to do so there are about 3 billion hurdles.
I am using visual studio 2010 though I have tried before with gcc which wasn't working either.
OK. The example provided with swig is as such:
/* File : example.c *//* A global variable */double Foo = 3.0;/* Compute the greatest common divisor of positive integers */int gcd(int x, int y) { int g; g = y; while (x > 0) { g = x; x = y % x; y = g; } return g;}
and
/* File : example.i */%module example%inline %{extern int gcd(int x, int y);extern double Foo;%}
So it shouldn't be at all complicated?
I start off by running the interface file through swig:
swig.exe -python example.i
Which works to give me my example_wrap.c
It seems the next step is to compile the project with example.c and example_wrap.c in the form of a dll.
So I convert the visual studio 6 project that comes with the example to vs2010 format, everything seems fine, all the settings are kept.
I had to set it to release mode so it could find the right python library (C:\python25\libs\python25.lib). But when I compile, visual studio can't find "tcl.h". tcl.h is included within the swig generated example_wrap.c file.
tcl.h isn't on my machine and no tutorials/guides even remotely speak of it, so I shouldn't really expect it to be a problem and I can't find any known fix for the issue. I notice that there is a tcl directory in my python directory (c:\python25\tcl), but there is just no header anywhere on my machine.
A quick google for tcl.h found it, so I put it in visual studio's include directory and now I am getting syntax errors in example_wrap.c:
Quote:1>ClCompile:
1> example_wrap.c
1>example_wrap.c(780): error C2143: syntax error : missing ')' before '*'
1>example_wrap.c(780): error C2081: 'Tcl_Obj' : name in formal parameter list illegal
1>example_wrap.c(780): error C2143: syntax error : missing '{' before '*'
1>example_wrap.c(780): error C2059: syntax error : ')'
1>example_wrap.c(781): error C2054: expected '(' to follow 'obj'
1>example_wrap.c(833): error C2143: syntax error : missing ')' before '*'
1>example_wrap.c(833): error C2081: 'Tcl_Obj' : name in formal parameter list illegal
1>example_wrap.c(833): error C2143: syntax error : missing '{' before '*'
1>example_wrap.c(833): error C2059: syntax error : '['
1>example_wrap.c(833): error C2059: syntax error : ')'
1>example_wrap.c(834): error C2143: syntax error : missing ')' before '*'
1>example_wrap.c(834): error C2081: 'Tcl_Obj' : name in formal parameter list illegal
...
..
.
They go onwards for about 100 lines. All the errors seem to be somehthing to do with tcl, which I discover via wikipedia is "Tool Command Language" and seems like it would be a component part of what makes python and c extensions work together. But considering not a single tutorial or guide on making python c extensions even mentions tcl, I shouldn't be having a problem with it :S The whole point in using swig is so I can avoid any issues like this isn't it?
If I follow a tutorial or guide it just takes me as far as I have got except things miraculously work without throwing syntax errors in files which I shouldn't have to be worrying about.
I don't know what I can do next to get extensions to work. It shouldn't be even remotely complicated but everything I do just leads to a mess of problems.
Has anybody tackled this problem before?
I could probably do what swig does manually, I am only going to be playing around with a few basic functions so I probably don't need the added complexity. Or would I be wrong about that?