External code and functions integration

Discussion in 'Python' started by Cro, Sep 22, 2008.

  1. Cro

    Cro Guest

    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.
    Cro, Sep 22, 2008
    #1
    1. Advertising

  2. Cro schrieb:
    > 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.


    Because you need to load the DLL.

    Diez
    Diez B. Roggisch, Sep 22, 2008
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Scott Allen
    Replies:
    8
    Views:
    10,910
    Scott Allen
    May 2, 2004
  2. Xiangliang Meng
    Replies:
    1
    Views:
    1,581
    Victor Bazarov
    Jun 21, 2004
  3. Daniel Vallstrom
    Replies:
    2
    Views:
    1,837
    Kevin Bracey
    Nov 21, 2003
  4. Djoudjou
    Replies:
    9
    Views:
    188
    Gregory Brown
    Sep 4, 2009
  5. Mellow Crow
    Replies:
    6
    Views:
    412
    Richard Cornford
    Nov 4, 2005
Loading...

Share This Page