Game Development Community

Linking libpython into TGE

by Brian Jones · in Torque Game Engine · 06/07/2003 (11:58 pm) · 2 replies

Hello,

I'm trying to get Joshua Ritters' TGEPython working under linux, but have encountered a problem. When I try to link the python library it generates the following errors:

--> Linking out.GCC2.DEBUG/torqueDemo_DEBUG.exe
../lib/out.GCC2.DEBUG/lpython_DEBUG.a(posixmodule.o)(.text+0x2a48): In function 'posix_tmpnam':
: the use of 'tmpnam_r' is dangerous, better use 'mkstemp'
../lib/out.GCC2.DEBUG/lpython_DEBUG.a(posixmodule.o)(.text+0x298a): In function 'posix_tempnam':
: the use of 'tempnam' is dangerous, better use 'mkstemp'
../lib/out.GCC2.DEBUG/lpython_DEBUG.a(posixmodule.o)(.text+0x1202): In function 'posix_openpty':
: undefined reference to 'openpty'
../lib/out.GCC2.DEBUG/lpython_DEBUG.a(posixmodule.o)(.text+0x125b): In function 'posix_forkpty':
: undefined reference to 'forkpty'
collect2: ld returned 1 exit status
make[1]: *** [out.GCC2.DEBUG/torqueDemo_DEBUG.exe] Error 1
make: *** [default] Error 2

I'm not even sure I am doing this right, but maybe someone can make some sense out of it. The following is what I have done:

Created TGEPython directory under ~/torque/engine and added the *.cc and *.h files, also copied python *.h files into here
Added libpython to ~/torque/lib/lpython directory, and renamed to lpython_DEBUG.a
Modified ~/torque/engine/targets.torque.mk to build in TGEPython code, and link lpython lib.
Tried to build it.

For starters, I imagine there is a better way to associate the python library and include files without having to actually copy them anywhere, yet still retain a system independant structure. I'll research that later, unless the answer impacts what I need to do to get this working correctly.

Besides that, I'm not entirely sure why the linker is breaking on this. Thanks for any advice :)

#1
06/08/2003 (5:39 am)
Looks like you just need to add -lpthread make sure you have all of the following in LINK.LIBS.GENERAL after -lSDL "-lpthread -ldl -lpython2.2 -ldl -lutil -lm". That *should* do it. If not ping me by email and I'll boot into Linux and see what other incantations might be needed.
#2
06/08/2003 (12:30 pm)
Well, it compiles this time with only the first two warnings (after googling around for pieces of the errors I found some messages on this), which only appear to be internal logic with python going weird, but can be ignored. The application segfaults however, bah! Thanks for the tip though, I now understand how to link to libs on the system.