Craig
September 2, 2010, 4:17am
1
I’m not sure where the proper place to post this is, but I have an issue. On Windows, I can’t include the Panda3D include directory. I get this error:
P:\CythonCXXTest\testc>ppython setup.py
running build_ext
cythoning testc.pyx to testc.cpp
building ‘testc’ extension
creating build
creating build\temp.win32-2.6
creating build\temp.win32-2.6\Release
C:\MinGW\bin\gcc.exe -mno-cygwin -mdll -O -Wall -IC:\Panda3D-1.7.0\include -IC:
Panda3D-1.7.0\python\include -IC:\Panda3D-1.7.0\python\PC -c testc.cpp -o build
temp.win32-2.6\Release\testc.o
In file included from C:/Panda3D-1.7.0/include/pandabase.h:22,
from C:/Panda3D-1.7.0/include/geom.h:18,
from testc.cpp:199:
C:/Panda3D-1.7.0/include/dtoolbase.h:158:20: minmax.h: No such file or directory
In file included from C:/Panda3D-1.7.0/include/cmath.h:67,
from C:/Panda3D-1.7.0/include/stl_compares.h:19,
from C:/Panda3D-1.7.0/include/pmap.h:20,
from C:/Panda3D-1.7.0/include/threadSimpleManager.h:24,
from C:/Panda3D-1.7.0/include/threadSimpleImpl.h:150,
from C:/Panda3D-1.7.0/include/mutexSimpleImpl.h:24,
from C:/Panda3D-1.7.0/include/mutexTrueImpl.h:38,
from C:/Panda3D-1.7.0/include/mutexDebug.h:19,
from C:/Panda3D-1.7.0/include/lightMutex.h:19,
from C:/Panda3D-1.7.0/include/typedWritable.h:21,
from C:/Panda3D-1.7.0/include/typedWritableReferenceCount.h:20,
from C:/Panda3D-1.7.0/include/cachedTypedWritableReferenceCount
.h:20,
from C:/Panda3D-1.7.0/include/copyOnWriteObject.h:20,
from C:/Panda3D-1.7.0/include/geom.h:19,
from testc.cpp:199:
C:/Panda3D-1.7.0/include/cmath.I: In function void csincos(float, float*, float *)': C:/Panda3D-1.7.0/include/cmath.I:74: error: expected
(’ before ‘{’ token
C:/Panda3D-1.7.0/include/cmath.I:74: error: expected asm body before ‘{’ token
C:/Panda3D-1.7.0/include/cmath.I:75: error: `mov’ was not declared in this scope
C:/Panda3D-1.7.0/include/cmath.I:75: error: expected ;' before "eax" C:/Panda3D-1.7.0/include/cmath.I:75: warning: unused variable 'mov' C:/Panda3D-1.7.0/include/cmath.I: In function
void csincos(double, double*, dou
ble*)‘:
C:/Panda3D-1.7.0/include/cmath.I:237: error: expected (' before '{' token C:/Panda3D-1.7.0/include/cmath.I:237: error: expected asm body before '{' token C:/Panda3D-1.7.0/include/cmath.I:238: error:
mov’ was not declared in this scop
e
C:/Panda3D-1.7.0/include/cmath.I:238: error: expected `;’ before “eax”
C:/Panda3D-1.7.0/include/cmath.I:238: warning: unused variable ‘mov’
error: command ‘gcc’ failed with exit status 1
P:\CythonCXXTest\testc>
It works fine on Mac. The project in question (a nice minimal sample for using Panda’s C++ API from cython) is here: craig.p3dp.com/Examples/Cython/testc/
On the Mac, I get this output, the later part of which is the output produced by the compiled module:
This works great.
Cython works fine with C++ for me on Windows when I don’t include Panda’s include directory.
If I can get this resolved, I’ll publish my little example along with instructions and information.
drwr
September 2, 2010, 4:45pm
2
Panda isn’t currently compilable by MinGW. It might be possible to make it work on that compiler (we were unable to years ago, due to a problem with DLL specification, but maybe things are better now). But it would be a lot of work, even if it is possible.
On Windows, you have to use MSVC to compile Panda.
David
Craig
September 2, 2010, 5:54pm
3
drwr:
Panda isn’t currently compilable by MinGW. It might be possible to make it work on that compiler (we were unable to years ago, due to a problem with DLL specification, but maybe things are better now). But it would be a lot of work, even if it is possible.
On Windows, you have to use MSVC to compile Panda.
David
I’m not trying to compile panda. I’m trying to compile a cython module that links against panda (I think thats the proper terminology). I can compile cython modules that make calls into python that was compiled with panda using MinGW just fine (in C or C++). But if I try to use any of panda’s harder files, I get that problem. Do you still think I should need MSVC?
Using distutils with cython and MinGW produced compiled modules that worked with Panda’s python just fine, no trouble at all (I didn’t have to mess with any settings at all). But, if I try to extern something from a panda header file, it spews the error.
Edit: I looked in cmath.I and it seems the issues are occurring on __asm blocks for csincos. Perhaps its failing to process inline asm functions, which I imagine I can’t simply skip, but I don’t need.
drwr
September 2, 2010, 8:14pm
4
Parsing a header file is the same thing as compiling. If you can expose only code that doesn’t require exposing a Panda header file, you should be OK. This may mean placing the #include “panda.h” or whatever in a .cpp file only, and not in a .h file that will be parsed by MinGW.
David
Craig
September 2, 2010, 8:59pm
5
drwr:
Parsing a header file is the same thing as compiling. If you can expose only code that doesn’t require exposing a Panda header file, you should be OK. This may mean placing the #include “panda.h” or whatever in a .cpp file only, and not in a .h file that will be parsed by MinGW.
David
Cython makes a .cpp file, and no .h files at all, so I have exactly 0 .h files already, and only one .cpp file with only one include from panda, #include “geom.h”
Here is the c++ file Cython generates: craig.p3dp.com/Misc/testc.cpp
MinGW seems to dislike the syntax for the __asm blocks. It expects a ( and not a { from what I can tell. I hacked cmath.I so it avoids them (they are already wrapped in an if statement), and commented out the include for minmax.h in dtoolbase.h which got it past those issues, but produced this error:
P:\CythonCXXTest\testc>ppython setup.py
running build_ext
cythoning testc.pyx to testc.cpp
building ‘testc’ extension
C:\MinGW\bin\gcc.exe -mno-cygwin -mdll -O -Wall -IP:\include -IC:\Panda3D-1.7.0
python\include -IC:\Panda3D-1.7.0\python\PC -c testc.cpp -o build\temp.win32-2.6
\Release\testc.o
writing build\temp.win32-2.6\Release\testc.def
C:\MinGW\bin\g++.exe -mno-cygwin -shared -s build\temp.win32-2.6\Release\testc.o
build\temp.win32-2.6\Release\testc.def -LC:\Panda3D-1.7.0\python\libs -LC:\Pand
a3D-1.7.0\python\PCbuild -lpython26 -lmsvcr90 -o P:\CythonCXXTest\testc\testc.py
d
build\temp.win32-2.6\Release\testc.o:testc.cpp:(.text$ZN9Socket_IP15force_init
typeEv[Socket_IP::force_init_type()]+0x46): undefined reference to TypedObject: :init_type()' build\temp.win32-2.6\Release\testc.o:testc.cpp:(.text$_ZN9Socket_IP15force_init_ typeEv[Socket_IP::force_init_type()]+0x7a): undefined reference to
TypedObject:
:type_handle’
build\temp.win32-2.6\Release\testc.o:testc.cpp:(.text$ZN9Socket_IP15force_init
typeEv[Socket_IP::force_init_type()]+0x8c): undefined reference to TypeRegistry ::ptr()' build\temp.win32-2.6\Release\testc.o:testc.cpp:(.text$_ZN9Socket_IP15force_init_ typeEv[Socket_IP::force_init_type()]+0x9b): undefined reference to
Socket_IP::
type_handle’
build\temp.win32-2.6\Release\testc.o:testc.cpp:(.text$ZN9Socket_IP15force_init
typeEv[Socket_IP::force_init_type()]+0xa3): undefined reference to TypeRegistry ::register_type(TypeHandle&, std::string const&)' build\temp.win32-2.6\Release\testc.o:testc.cpp:(.text$_ZN9Socket_IP15force_init_ typeEv[Socket_IP::force_init_type()]+0xb6): undefined reference to
Socket_IP::_
type_handle’
build\temp.win32-2.6\Release\testc.o:testc.cpp:(.text$ZN9Socket_IP15force_init
typeEv[Socket_IP::force_init_type()]+0xbe): undefined reference to TypeRegistry ::ptr()' build\temp.win32-2.6\Release\testc.o:testc.cpp:(.text$_ZN9Socket_IP15force_init_ typeEv[Socket_IP::force_init_type()]+0xd4): undefined reference to
TypeRegistry
::record_derivation(TypeHandle, TypeHandle)’
build\temp.win32-2.6\Release\testc.o:testc.cpp:(.text$ZN9Socket_IP15force_init
typeEv[Socket_IP::force_init_type()]+0x292): undefined reference to Socket_IP:: _type_handle' build\temp.win32-2.6\Release\testc.o:testc.cpp:(.text$_ZNK9Socket_IP8get_typeEv[ Socket_IP::get_type() const]+0x8): undefined reference to
Socket_IP::_type_hand
le’
build\temp.win32-2.6\Release\testc.o:testc.cpp:(.text$_ZN9Socket_IPD0Ev[Socket_I
P::~Socket_IP()]+0x6f): undefined reference to TypedObject::~TypedObject()' build\temp.win32-2.6\Release\testc.o:testc.cpp:(.text$_ZN9Socket_IPD0Ev[Socket_I P::~Socket_IP()]+0x93): undefined reference to
TypedObject::~TypedObject()’
build\temp.win32-2.6\Release\testc.o:testc.cpp:(.text$_ZN9Socket_IPD0Ev[Socket_I
P::~Socket_IP()]+0x98): undefined reference to memory_hook' build\temp.win32-2.6\Release\testc.o:testc.cpp:(.text$_ZN9Socket_IP5CloseEv[Sock et_IP::Close()]+0x17): undefined reference to
closesocket@4’
build\temp.win32-2.6\Release\testc.o:testc.cpp:(.text$_ZN9Socket_IPD1Ev[Socket_I
P::~Socket_IP()]+0x6f): undefined reference to TypedObject::~TypedObject()' build\temp.win32-2.6\Release\testc.o:testc.cpp:(.text$_ZN9Socket_IPD1Ev[Socket_I P::~Socket_IP()]+0x93): undefined reference to
TypedObject::~TypedObject()’
collect2: ld returned 1 exit status
error: command ‘g++’ failed with exit status 1
P:\CythonCXXTest\testc>
I suspect messing with the header files is probably not a good thing to do, but at least I made something different happen. It managed to make a .o and .def file that time.
Would be be good for me to try some simpler (trivial) C++ file? I don’t actually know C++, and I’ve never really done anything with header files, so I don’t know what to try. I tried a cpp file with nothing in it other than #include “geom.h” but it does the same thing (the error in my first post and the one above respectively) as the whole big Cython generated c++ file with both the the original and my modified header files.
Craig
September 2, 2010, 11:05pm
6
I’m installing Microsoft Visual Studio 2008 C++ Express Edition. Maybe this will make it work. Thanks for the suggestions!
Craig
September 3, 2010, 12:57am
7
Well, I got a c++ Cython sample to compile with MSVC compiler, but I can’t make it work with Panda!
I get this:
C:\Users\Craig\Desktop\CythonCXXTest\testc>ppython setup.py
running build_ext
building ‘testc’ extension
C:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\BIN\cl.exe /c /nologo /Ox
/MD /W3 /GS- /DNDEBUG -IC:\Panda3D-1.7.0\include -IC:\Panda3D-1.7.0\python\inclu
de -IC:\Panda3D-1.7.0\python\PC /Tptestc.cpp /Fobuild\temp.win32-2.6\Release\tes
tc.obj
testc.cpp
C:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\INCLUDE\xlocale(342) : war
ning C4530: C++ exception handler used, but unwind semantics are not enabled. Sp
ecify /EHsc
C:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\INCLUDE\vector(439) : warn
ing C4275: non dll-interface class ‘std::_Container_base_aux’ used as base for d
ll-interface class ‘std::_Container_base_aux_alloc_real<_Alloc>’
with
[
_Alloc=pallocator_array<TypedWritable *>
]
C:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\INCLUDE\xutility(3
77) : see declaration of ‘std::_Container_base_aux’
c:\panda3d-1.7.0\include\vector_src.h(64) : see reference to class templ
ate instantiation ‘std::vector<_Ty,_Ax>’ being compiled
with
[
_Ty=TypedWritable *,
_Ax=pallocator_array<TypedWritable *>
]
C:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\INCLUDE\vector(439) : warn
ing C4275: non dll-interface class ‘std::_Container_base_aux’ used as base for d
ll-interface class ‘std::_Container_base_aux_alloc_real<_Alloc>’
with
[
_Alloc=pallocator_arraystd::string
]
C:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\INCLUDE\xutility(3
77) : see declaration of ‘std::_Container_base_aux’
c:\panda3d-1.7.0\include\vector_src.h(64) : see reference to class templ
ate instantiation ‘std::vector<_Ty,_Ax>’ being compiled
with
[
_Ty=std::string,
_Ax=pallocator_arraystd::string
]
C:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\INCLUDE\vector(439) : warn
ing C4275: non dll-interface class ‘std::_Container_base_aux’ used as base for d
ll-interface class ‘std::_Container_base_aux_alloc_real<_Alloc>’
with
[
_Alloc=pallocator_array
]
C:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\INCLUDE\xutility(3
77) : see declaration of ‘std::_Container_base_aux’
c:\panda3d-1.7.0\include\vector_src.h(64) : see reference to class templ
ate instantiation ‘std::vector<_Ty,_Ax>’ being compiled
with
[
_Ty=unsigned char,
_Ax=pallocator_array
]
C:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\INCLUDE\vector(439) : warn
ing C4275: non dll-interface class ‘std::_Container_base_aux’ used as base for d
ll-interface class ‘std::_Container_base_aux_alloc_real<_Alloc>’
with
[
_Alloc=pallocator_array
]
C:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\INCLUDE\xutility(3
77) : see declaration of ‘std::_Container_base_aux’
c:\panda3d-1.7.0\include\vector_src.h(64) : see reference to class templ
ate instantiation ‘std::vector<_Ty,_Ax>’ being compiled
with
[
_Ty=int,
_Ax=pallocator_array
]
C:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\BIN\link.exe /DLL /nologo
/INCREMENTAL:NO /LIBPATH:C:\Panda3D-1.7.0\python\libs /LIBPATH:C:\Panda3D-1.7.0
python\PCbuild /EXPORT:inittestc build\temp.win32-2.6\Release\testc.obj /OUT:C:
Users\Craig\Desktop\CythonCXXTest\testc\testc.pyd /IMPLIB:build\temp.win32-2.6\R
elease\testc.lib /MANIFESTFILE:build\temp.win32-2.6\Release\testc.pyd.manifest
LINK : error LNK2001: unresolved external symbol inittestc
build\temp.win32-2.6\Release\testc.lib : fatal error LNK1120: 1 unresolved exter
nals
error: command ‘“C:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\BIN\link.
exe”’ failed with exit status 1120
C:\Users\Craig\Desktop\CythonCXXTest\testc>
I’m pretty clueless for how to progress from here. Any advice would be greatly appreciated.
Edit: I should mention that just as with MinGW, Cython works just fine as long as I don’t try to include any panda headers.
Craig
September 3, 2010, 9:48pm
8
I think I’ve resolved all the compiler and Panda issues. I suspect my current issue (see last post) is a Cython bug, recorded here: trac.cython.org/cython_trac/ticket/106
Thanks for the help!
I’ll keep an eye on it and if I get it to work, I’ll be back with a fix.