title: swig no module named _example
body: <p>I cannot reproduce the basic SWIG example on windows.
  My error is stated in the SWIG docs and I am sure that I do the 2 fixes they mention. For this error:</p>
  
  <pre><code>&gt;&gt;&gt; import example
  Traceback (most recent call last):
    File "&lt;stdin&gt;", line 1, in ?
    File "example.py", line 2, in ?
      import _example
  ImportError: No module named _example
  </code></pre>
  
  <p>the SWIG documentation clearly states:</p>
  
  <p>forget the leading underscore (_).</p>
  
  <p>forget the leading underscore (_).> If you get this message, it means that</p>
  
  <blockquote>
    <p>you either forgot to compile the
    wrapper code into an extension module
    or you didn't give the extension
    module the right name. Make sure that
    you compiled the wrappers into a
    module called <em>example.so. And don't
    forget the leading underscore (</em>).forget the leading underscore (_).</p>
  </blockquote>
  
  <p>and I am sure that I link with the latest wrap object build and I have tryied: "_example", "_example.so", "<em>example.dll", "example.so", "example.dll", even all at once, and that the generated "example.py" is in the same folder as the shared library, and that the python path contains this directoryforget the leading underscore (</em>).</p>
  
  <p>THE EXAMPLE:</p>
  
  <pre><code>//example.h
  int foo_sum(int a, int b);
  </code></pre>
  
  <p>.</p>
  
  <pre><code>//example.cpp
  int foo_sum(int a, int b) {
      return a + b;
  }
  </code></pre>
  
  <p>.</p>
  
  <pre><code>//example.i
  %module example
  %{
  #include "example.h"
  %}
  
  #include "example.h
  </code></pre>
  
  <p>and the build commands:</p>
  
  <pre><code>gcc -IV:\temp\example\external\include\Python -O3 -Wall -c -fmessage-length=0 -oexample_wrap.o ..\example_wrap.c
  g++ -IV:\temp\example\external\include\Python -O3 -Wall -c -fmessage-length=0 -oexample.o ..\example.cpp
  g++ -LV:\temp\example\external\lib -shared -oexample.dll example_wrap.o example.o -lpython26
  </code></pre>
  
  <p>even if I don't use -O3 it still doesn't work (I pasted the build commands from a Release configuration)</p>
  
  <p>I also tried this and to no success:</p>
  
  <pre><code>&gt;&gt;&gt; import sys
  &gt;&gt;&gt; sys.path.append("/your/module/path")
  &gt;&gt;&gt; import example
  </code></pre>
  
  <p>EDIT:</p>
  
  <p>apparently it loads the dll if you rename it to "_example.pyd", BUT the module loaded does not contain my "foo_sum" function</p>
  
  <p>EDIT:
  it works now, I am using extern "C" and not including headers in the .i file</p>