External code and functions integration

Cro prahaai at gmail.com
Mon Sep 22 09:13:50 CEST 2008


Good day.

I am using python for quite some time now and i decided to advance a
little. I want to write a little extension, or add some C modules for
my python. I use Active version.

What i want to do is write some wrappers for a game library, called
HGE. See "hge.relishgames.com".
I wrote some applications with HGE, in C++ and i like it pretty much.
In order to make a HGE application in C++, i need to include "hge.h",
include "hge.lib" and "hgelehper.lib", and have "hge.dll" in the same
directory. So it's 3 things i must have for the program to work.
This game library is open source, so i have the source for the libs
and the dll.

Now, what i was thinking was to make some wrapping code like "hge.h"
to call all the functions in the "libs", that (i guess) call the
functions from "hge.dll", that (blah blah) calls DirectX and so on.
I guess that if i write all that "hge.h" includes and wariables in
python, will be okay... even if i still don't have the skill.

I tried to call "hge.lib" like this:
"
from ctypes import *
cdll.LoadLibrary("D:/HGE18/lib/bc/hge.lib")
"
But i get "WindowsError: [Error 193] %1 is not a valid Win32
application".
I tried with windll.LoadLibrary ... and i get the same error.
I tried with the other lib versions, there are 3 versions: BorlandC,
GCC, VisualC, callind "cdll" or "windll". All lib versions report the
same error.



Recently i discovered PyInline and SciPy Weave. They say that Weave
can run C code on the fly, inline... I really dobt that it can parse
things like:
"
#ifndef HGE_H
#define HGE_H
"
or:
"
#include <windows.h>

#define HGE_VERSION 0x180

#ifdef HGEDLL
#define EXPORT __declspec(dllexport)
#else
#define EXPORT
#endif

#define CALL __stdcall
"

Has anyone ever encountered a problem like this ?
Any, ANY advice or idea would be useful !
Thank you very much.



More information about the Python-list mailing list