newbie problem with wrapping c++ code

"Hoyt Koepke" <[email protected]>
Newsgroups gmane.comp.python.pyrex
Message-ID <[email protected]>
Hello,

I'm a first-day newbie at pyrex, and I'm having some trouble wrapping
some cpp code. I've spent quite a while searching around the internet,
but I can't seem to discover what I'm doing wrong.

Here's my .pyx file:

++++++++++++++++++++++++++++
cdef extern from "ccode/test.h":
    void hello_world()

def helloWorld():
   hello_world()
++++++++++++++++++++++++++++

ccode/test.h is just:

++++++++++++++++++++++++++++
void hello_world();
++++++++++++++++++++++++++++


and ccode/test.cpp is:

++++++++++++++++++++++++++++
#include <iostream>
#include "test.h"

using namespace std;

void hello_world()
{
 cout << "hello, world." << endl;
}
++++++++++++++++++++++++++++

I'm using the numpy.distutils package to try to compile the code (I
need numpy.distutils for the rest of the project):

++++++++++++++++++++++++++++
#!/usr/bin/env python

from os.path import join, split

cdir = 'ccode'

def configuration(parent_package='',top_path=None):
   from numpy.distutils.misc_util import Configuration, get_mathlibs
   config = Configuration('',parent_package,top_path)

   config.add_extension('test',
                        sources=[join(cdir, 'test.cpp'), 'test.pyx'],
                        depends=[join(cdir, 'test.h'), 'test.pyx'],
                        language="c++"
                        )
   return config

if __name__ == '__main__':
   from numpy.distutils.core import setup
   setup(configuration=configuration)
++++++++++++++++++++++++++++

Anyway, the error I'm getting when I try to import the new module is:

>>> import test
Traceback (most recent call last):
 File "<stdin>", line 1, in <module>
ImportError: ./test.so: undefined symbol: hello_world

What am I doing wrong?  I'm sure it's something very simple...

Thanks!
--Hoyt

-- 
+++++++++++++++++++++++++++++++++++
Hoyt Koepke
UBC Department of Computer Science
http://www.cs.ubc.ca/~hoytak/
[email protected]
+++++++++++++++++++++++++++++++++++
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.