|Newbie questions about Pliant
Compiling WIN32API calling convention DLL for XP and 9X.
I was succesfull in re-building the SDL.DLL to use the
undecorated __stdcall (WIN32API) calling convention. Pliant
can use the DLL in XP, but not in 9x/Me.
|Message posted by mujtaba on 2003/09/28 02:23:54
|With some code changes in the headers, and with help from this site,
I was able to compile SDL to use undecorated __stdcall calling convention,
instead of the default __cdecl convention. This allows me to run Pliant+SDL
programs in the Windows environment (with DirectX!). I did this using
VC++ 7.0 in the labs at school. It worked in Windows XP professional,
but when I bring the DLL home, pliant fails to load it. Infact, Windows doesn't
seem to recognize it as a DLL when I check the properties. Yet DLL tools such
as objdump and pexports tell me its a valid DLL format.
This is my first time trying to port a library for windows to use under pliant.
I understand libs such as Zlib had its share of headaches. Has anything like
this happened? Could there be a reason why a DLL I compiled on one Windows
workstation not work on another? Thanks.
|Message posted by hubert.tonneau on 2003/09/28 07:08:53
|I bet your SDL library depends on something else than the core kernel DLL,
and that one of the DLL it depends (might be DirectX) does not exist in the
old system, or is too old.
|Message posted by mujtaba on 2003/09/28 10:56:08
|I'm trying to recompile SDL using mingw/cygwin on my old system. I'll try to
compile a simple GDI and winmm version of SDL. No luck just yet. SDL is
by default, built as __decl like most UNIX libraries that get ported to win32.
It would be nice if Pliant could just switch call conventions for libs
external_decl "foo.dll" "foo"
|Message posted by hubert.tonneau on 2003/09/28 11:49:02
|You may try something like this:
external "foo.dll" "foo"
I don't know if it works.
|Message posted by hubert.tonneau on 2003/09/28 11:56:15
|You may need to patch function 'Function_terminate_arguments_prototypes'
in module /pliant/language/compiler/function/function.pli
with the following line:
rules=(f->flags&Function_flag_varargs ? &varargs_rules : (f->flags&Function_flag_kernel ? &kernel_rules : (f->flags&Function_flag_external ? &external_rules : &compiler_rules)));
|Message posted by mujtaba on 2003/09/30 20:29:37
|You were right, there was a DLL missing. You see, I used Visual C++ .Net at
school,and it compiles executables, which uses MSVCR71.DLL instead of the
MSVCRT.DLL for its standard C runtime. I copied the DLL, and now it works
on 9X/ME too.
I still can't get it to compile with mingw, though. I hate having to depend
on VC++. Also, both MSVCRT.DLL and MSVCR71.DLL use the __decl calling convention
which is stupid because every other Windows DLL uses __stdcall. Now I have to
find a C runtime DLL which uses __stdcall, since I can't obviously recompile
MSVCRT.DLL without its sources.
One of my demos uses ANSI C rand and time functions, I need to find
equivalents in Pliant.
|Message posted by hubert.tonneau on 2003/09/30 20:54:23
|> One of my demos uses ANSI C rand and time functions, I need to find
> equivalents in Pliant.
memory_random addressof:(var Int i) Int:size
|Message posted by mujtaba on 2003/10/01 22:27:53
|Is there a way to "seed" this random generator with the current time?
|Message posted by hubert.tonneau on 2003/10/01 22:34:38
|No. But you don't need it.
If you want something more random than memory_random (which is basically
equivalent to Unix rand), then use:
memory_strong_random addressof:(var Int i) Int:size
This one will automatically seed itself.