PDA

View Full Version : Compiling SDL for WINCE



MoRLoP
23-09-2007, 07:18 PM
Hi all!,
I'm trying to crosscompile a foo JEDI-SDL based application for WinCE ARM.
I'm using las Lazarus snapshot, and the last WINCE add-in under Windows XP SP2.
Whenever I try to compile for WINCE I get the following errors:


project1.lpr(16) Error: Undefined symbol: SDL__PUTENV$PCHAR$$LONGINT
project1.lpr(16) Error: Undefined symbol: SDL_GETENV$PCHAR$$PCHAR
project1.lpr(16) Fatal: There were 2 errors compiling module, stopping


Taking a look at the sources, it seems like those functions are declared to be external in MSVCRT.dll. They might not exist for Wince, I don't know.

This the sourcecode I'm trying to compile (I think the compiler it's properly set up, because non-sdl applications are working perfectly):

program project1;

{$mode delphi}


uses
sdl;

var scr: PSDL_Surface; // Our main screen

begin
SDL_Init(SDL_INIT_VIDEO); // Initialize the video SDL subsystem
scr:=SDL_SetVideoMode(640, 480, 8, SDL_SWSURFACE); // Create a software window of 640x480x8 and assign to scr
SDL_Quit; // close the subsystems and SDL
end.

Has anybody succeded in compiling JEDI-SDL for WINCE?

Thanks in advance,

MoRLoP

technomage
23-09-2007, 07:30 PM
Do you know what conditional define is required for WINCE?

I'm not sure if the JEDI-SDL headers have implemented the correct stubs for Get and Put Env.

MoRLoP
24-09-2007, 03:14 PM
Hi Technomage,
I think I understood the problem, but I have still some problems..
I implemented getenv and putenv and now it compiles and links perfectly.


{$mode delphi}

unit getenv;

interface

uses
Classes, SysUtils;

function SDL_putenv(const variable: PChar): integer;
function SDL_getenv(const name: PChar): PChar;
function _putenv( const variable : Pchar ): integer;
function _getenv( const name : Pchar ): PChar;
function getenv( const name : Pchar ): PChar;
function putenv(const variable: PChar): integer;

implementation
type
REnv_var=record
name:string;
value:string;
end;
var
SDL_env: array of REnv_var;
{ Put a variable of the form "name=value" into the environment. }
function SDL_putenv(const variable: PChar): integer;
var
name, value: string;
i,added: integer;
env_var: REnv_var;
begin
if variable=nil then begin
result:=-1;
exit;
end;

name:= String(variable);
i:=Pos('=',name);
if (i=0) then begin
result:=-1;
exit;
end;

{ Take the values }
env_var.value:=Trim(Copy(name, i+1, Length(name)-i));
env_var.name:=Trim(Copy(name, 1, i-1));

{ Check the variable is not already in the environment.
If it is, replace it. }
added:=-1;
For i:=0 to Length(SDL_env)-1 do begin
if (SDL_env[i].name=env_var.name) then begin
SDL_env[i].value:=env_var.value;
added:=0;
Break;
end;
end;

if (added=-1) then begin
SetLength(SDL_env, Length(SDL_env)+1);
SDL_env[Length(SDL_env)-1].value:=env_var.value;
SDL_env[Length(SDL_env)-1].name:=env_var.name;
added:=0;
end;

Result:=added;
end;

function SDL_getenv(const name: PChar): PChar;
var
vname, venv: String;
i:integer;
begin
vname:=String(name);

For i:=0 to Length(SDL_env)-1 do begin
if (SDL_env[i].name=vname) then begin
venv:=SDL_env[i].name+'='+SDL_env[i].value;
Result:=PChar(venv);
break;
end;
end;
end;

function _putenv( const variable : Pchar ): integer;
begin
Result:=SDL_putenv(variable);
end;

function putenv( const variable : Pchar ): integer;
begin
Result:=SDL_putenv(variable);
end;

function _getenv( const name : Pchar ): PChar;
begin
Result:=SDL_getenv(name);
end;

function getenv( const name : Pchar ): PChar;
begin
Result:=SDL_getenv(name);
end;

end.

However, I get the following message whenever I try to execute the SDL-based application:

"The file 'project1' cannot be opened. Either it is not signed with a trusted certificate, or one of its components cannot be found. If the problem persists, try reinstalling or restoring this file."

I think it is because I still need a DLL (SDL.dll for WINCE), therefore I'm going to compile the original SDL for WINCE using a C compiler and see if it works. I will post my progress.

Best regards,

MoRLoP

savage
25-09-2007, 04:26 PM
Hi MoRLoP,
This is great news that you are looking at getting WinCE support for JEDI-SDL.

With regard to your problem...It's very strange that FPC complains about "Undefined symbol: SDL__PUTENV" because SDL_Putenv is a locally defined function and the the OS specific _putenv and _getenv functions are externally defined.

Are you using the latest snapshot from http://jedi-sdl.pascalgamedevelopment.com ? because is sounds like you may be using a very old version of the JEDI-SDL headers.

You may also want to have a look at this thread (http://groups.google.com/group/microsoft.public.pocketpc.developer/browse_thread/thread/3a3c136ea038644e/fd65173eb2867abd?hl=en&lnk=st&q=WinCE+not+signed+trusted+certificate&rnum=1#fd65173eb2867abd)
It discusses the "not signed with a trusted certificate" issue, but I'm not sure if it will help.

MoRLoP
26-09-2007, 12:31 PM
Hi Savage!,
I already got it working.
As I had supposed it required SDL.dll compiled for WINCE.
The problem with putenv and getenv is that they are probably not available for WINCE, or they are implemented in a different DLL. as far as I found they are not available for WINCE according to MSDN.

I will make a post with my changes to the sources of JEDI-SDL to got it working ASAP.

The problem now is that the demos are not working, and still don't know why ... ;)

Best regards,

MoRLoP

savage
26-09-2007, 12:49 PM
Great news, I look forward to seeing your changes so I can incorporate them into JEDI-SDL.