Problems calling C dll function, timeout.

Just starting out? Need help? Post your questions and find answers here.
Surp
New User
New User
Posts: 5
Joined: Sat May 14, 2011 1:55 pm

Problems calling C dll function, timeout.

Post by Surp »

Hi
i'm stuck trying to call a function in a dll.

This is the C function i' trying to call:

Code: Select all

enum
{
    sfNone       = 0,      ///< No border / title bar (this flag and all others are mutually exclusive)
    sfTitlebar   = 1 << 0, ///< Title bar + fixed border
    sfResize     = 1 << 1, ///< Titlebar + resizable border + maximize button
    sfClose      = 1 << 2, ///< Titlebar + close button
    sfFullscreen = 1 << 3  ///< Fullscreen mode (this flag and all others are mutually exclusive)
};

typedef struct
{
    unsigned int DepthBits;         ///< Bits of the depth buffer
    unsigned int StencilBits;       ///< Bits of the stencil buffer
    unsigned int AntialiasingLevel; ///< Level of antialiasing
} sfWindowSettings;

typedef struct
{
    unsigned int Width;        ///< Video mode width, in pixels
    unsigned int Height;       ///< Video mode height, in pixels
    unsigned int BitsPerPixel; ///< Video mode pixel depth, in bits per pixels
} sfVideoMode;

CSFML_API sfWindow* sfWindow_Create(sfVideoMode Mode, const char* Title, unsigned long Style, sfWindowSettings Params);
This is the PB code:

Code: Select all

Enumeration
  #sfNone = 0
  #sfTitlebar = 1 << 0
  #sfResize = 1 << 1
  #sfClose = 1 << 2
  #sfFullscreen = 1 << 3
EndEnumeration

Structure sfWindowSettings
  DepthBits.i
  StencilBits.i
  AntialiasingLevel.i
EndStructure

Structure sfVideoMode   
  Width.i
  Height.i
  BitsPerPixel.i
EndStructure

ImportC "csfml-window.lib"

  sfWindow_Create(*Mode.sfVideoMode,Title.s,Style,*Params.sfWindowSettings) 
  
EndImport

Settings.sfWindowSettings\DepthBits = 24
Settings\StencilBits = 8
Settings\AntialiasingLevel = 0
Mode.sfVideoMode\Width = 800
Mode\Height = 600
Mode\BitsPerPixel = 32

sfWindow_Create(@Mode, "SFML window", sfResize | sfClose, @Settings)
I don't really get a error just timeout:
[14:51:48] Waiting for executable to start...
[14:51:58] The debugged executable did not respond to communication for %timeout% seconds. Disconnecting.

If I comment out sfWindow_Create() it doesnt timeout, but if I put a breakpoint on that function call it doesn't even reach it.

I hope someone can help, thanks beforehand.
KarLKoX
Enthusiast
Enthusiast
Posts: 681
Joined: Mon Oct 06, 2003 7:13 pm
Location: France
Contact:

Re: Problems calling C dll function, timeout.

Post by KarLKoX »

Hi !

Doesn't occure when turning off the debugger.
Perhaps you need to use the lib debug version of CSFML with pb debugger enabled :?:
"Qui baise trop bouffe un poil." P. Desproges

http://karlkox.blogspot.com/
Surp
New User
New User
Posts: 5
Joined: Sat May 14, 2011 1:55 pm

Re: Problems calling C dll function, timeout.

Post by Surp »

KarLKoX wrote:Hi !

Doesn't occure when turning off the debugger.
Perhaps you need to use the lib debug version of CSFML with pb debugger enabled :?:
The Debug version doesn't seem to change anything. :/
User avatar
idle
Always Here
Always Here
Posts: 5901
Joined: Fri Sep 21, 2007 5:52 am
Location: New Zealand

Re: Problems calling C dll function, timeout.

Post by idle »

what if you use the flags instead of passing in 0

Code: Select all

sfWindow_Create(@Mode, "SFML window", #sfResize | #sfClose, @Settings)
Windows 11, Manjaro, Raspberry Pi OS
Image
Surp
New User
New User
Posts: 5
Joined: Sat May 14, 2011 1:55 pm

Re: Problems calling C dll function, timeout.

Post by Surp »

idle wrote:what if you use the flags instead of passing in 0

Code: Select all

sfWindow_Create(@Mode, "SFML window", #sfResize | #sfClose, @Settings)
Yea well it doesnt change the fact that it never executes that line =/ i have no idea whats wrong.
User avatar
idle
Always Here
Always Here
Posts: 5901
Joined: Fri Sep 21, 2007 5:52 am
Location: New Zealand

Re: Problems calling C dll function, timeout.

Post by idle »

what version did you download?
I tried the c version of the VS 2005 build, none of the libs linked.
Windows 11, Manjaro, Raspberry Pi OS
Image
Surp
New User
New User
Posts: 5
Joined: Sat May 14, 2011 1:55 pm

Re: Problems calling C dll function, timeout.

Post by Surp »

SFML 1.6, VS 2008
eesau
Enthusiast
Enthusiast
Posts: 589
Joined: Fri Apr 27, 2007 12:38 pm
Location: Finland

Re: Problems calling C dll function, timeout.

Post by eesau »

Damn, I am having this exact same problem after trying SFML. Always getting a "Invalid memory access. (read error at address 0)". Surp, did you ever find a solution for this?
Trond
Always Here
Always Here
Posts: 7446
Joined: Mon Sep 22, 2003 6:45 pm
Location: Norway

Re: Problems calling C dll function, timeout.

Post by Trond »

Maybe the wrong calling convention is used when building the library. Maybe it's using fastcall instead of cdecl.
eesau
Enthusiast
Enthusiast
Posts: 589
Joined: Fri Apr 27, 2007 12:38 pm
Location: Finland

Re: Problems calling C dll function, timeout.

Post by eesau »

Trond wrote:Maybe the wrong calling convention is used when building the library. Maybe it's using fastcall instead of cdecl.
I doubt it but anything's possible. I'll continue trying, SFML looks like a great alternative to SDL.
eesau
Enthusiast
Enthusiast
Posts: 589
Joined: Fri Apr 27, 2007 12:38 pm
Location: Finland

Re: Problems calling C dll function, timeout.

Post by eesau »

Nevermind, the problem was yours truly. I was using the wrong libs :oops:
Post Reply