4 Sep 2010 00:15
"unresolved external symbol" On Windows trying to call Panda3D's C++ API
Craig Macomber <fishyfish55 <at> gmail.com>
2010-09-03 22:15:47 GMT
2010-09-03 22:15:47 GMT
I believe I might be seeing this issue, but I'm not sure: http://trac.cython.org/cython_trac/ticket/106 I'm trying to compile a trivial Cython script that makes a call into Panda3D's C++ API (Panda has a great python API, but it's easy to mix with the C++ API, which seems like a nice job for Cython). It works great for me on my Macs. On Windows, I have to use MSVC compiler (Form Visual Studio 2008 Express) to work with Panda3D, and I get this error when compiling: Creating library build\temp.win32-2.6\Release\testx.lib and object build\temp .win32-2.6\Release\testx.exp testc.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) pub lic: void __thiscall Geom::clear_cache(void)" (__imp_? clear_cache <at> Geom <at> <at> QAEXXZ) referenced in function "struct _object * __cdecl __pyx_pf_5testx_test(struct _ob ject *,struct _object *)" (? __pyx_pf_5testx_test <at> <at> YAPAU_object <at> <at> PAU1 <at> 0 <at> Z) P:\CythonCXXTest\testc\testx.pyd : fatal error LNK1120: 1 unresolved externals error: command '"C:\Program Files (x86)\Microsoft Visual Studio 9.0\VC \BIN\link. exe"' failed with exit status 1120 (Full output here: http://dpaste.com/238519/ ) My Cython source is: cdef extern from "geom.h": cdef cppclass Geom: void clear_cache() from panda3d.core import GeomVertexFormat,GeomVertexData from panda3d.core import Geom as pGeom print "Lets roll with C++" format=GeomVertexFormat.getV3n3c4t2() vdata=GeomVertexData('vdata', format, pGeom.UHStatic) geom=pGeom(vdata) v=geom.this print "getting ptr" cdef long dataPtr=v cdef Geom* g=<Geom*>dataPtr print "calling C++ method" g.clear_cache() print "done" My setup.py: import sys import os from distutils.core import setup from distutils.extension import Extension from Cython.Distutils import build_ext # make setup do what we want, # build extension modules in place sys.argv.append('build_ext') sys.argv.append('--inplace') if os.name=='nt': include_dirs=[r'C:\Panda3D-1.7.0\include'] elif os.name=='posix': include_dirs=['/Developer/Panda3D/include/'] else: # Specify Panda3D include directory here for other systems include_dirs=[''] setup( name = 'Demos', ext_modules=[ Extension("testx", sources=["testc.pyx"], language="c++", include_dirs=include_dirs, ), ], cmdclass = {'build_ext': build_ext}, ) print "Importing module" from panda3d.core import Geom import testx I have tried the the Rectangles C++ sample with this setup on Windows, and it did work fine, and if I remove the Call to panda's C++ API, my code works fine, so I'm pretty sure the issue is linked to the C++ call. If possible, I'd like to actually make this work on Windows. Any suggestions for what to try would be greatly appreciated as I'm completely out of ideas. I'd be happy to do further testing if it would help resolve the issue, but I don't know what to try. Thanks!
RSS Feed