[fpc-pascal] Fpc compiler error win32 "Entrypoint _mainCRTStartup not defined"

2006-11-07 Thread Marius

Hello,

Was trying the last trunk and got this error on the i386-win32. Its not 
a big deal, we still got a working fpc/lazarus for win32 & wince, just 
wundering if this is a known (or fixable) error.


cd \fpcsrc
make clean OS_TARGET=win32 CPU_TARGET=i386
make install OS_TARGET=win32 CPU_TARGET=i386

o:/fpc/bin/i386-win32/ppc386.exe -Ur -Xs -O2 -n -Fui386 -Fusystems 
-FuO:/Fpcsrc/rtl/units/i386-win32 -Fii386 -FE. -FUi386/units/i386-win32 
-dRELEASE  -di386 -dGDB -dBROWSERLOG -Fux86 pp.pas

pp.pas(210,1) Error: Entrypoint _mainCRTStartup not defined
pp.pas(210,1) Fatal: There were 1 errors compiling module, stopping
Fatal: Compilation aborted
make[5]: *** [ppc386.exe] Error 1
make[5]: Leaving directory `O:/Fpcsrc/compiler'
make[4]: *** [next] Error 2
make[4]: Leaving directory `O:/Fpcsrc/compiler'
make[3]: *** [ppc1.exe] Error 2
make[3]: Leaving directory `O:/Fpcsrc/compiler'
make[2]: *** [cycle] Error 2
make[2]: Leaving directory `O:/Fpcsrc/compiler'
make[1]: *** [compiler_cycle] Error 2
make[1]: Leaving directory `O:/Fpcsrc'
make: *** [build-stamp.i386-win32] Error 2


All happened after a clean...

Greetings,
Marius

___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


[fpc-pascal] Trying to convert some C code

2006-11-07 Thread Ole J. Røtne

Hello

Would any FPC guru help me converting this C code? 
(it's from bn.h/libeay32.dll)


typedef struct bignum_st BIGNUM;

struct bignum_st
{
  BN_ULONG *d;
  int top;
  int dmax;
  int neg;
  int flags;
};

char *BN_bn2hex(const BIGNUM *a);


I guess my problem is understanding pointers, and how they work.
Tried something like this (did cut some checks & stuff to make it short):

  _BnBn2Hex: TBN_bn2hex = nil;
Function InitLib:boolean;
Begin
  LibHandle := LoadLibrary('libeay32.dll');
  _BnBn2Hex := GetProcAddress( BnLibHandle, 'BN_bn2hex');
  result := true;
End;
End.

Ole JR

___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] Fpc compiler error win32 "Entrypoint _mainCRTStartup not defined"

2006-11-07 Thread Florian Klaempfl
Marius schrieb:
> Hello,
> 
> Was trying the last trunk and got this error on the i386-win32. Its not
> a big deal, we still got a working fpc/lazarus for win32 & wince, just
> wundering if this is a known (or fixable) error.
> 
> cd \fpcsrc
> make clean OS_TARGET=win32 CPU_TARGET=i386
> make install OS_TARGET=win32 CPU_TARGET=i386
> 
> o:/fpc/bin/i386-win32/ppc386.exe -Ur -Xs -O2 -n -Fui386 -Fusystems
> -FuO:/Fpcsrc/rtl/units/i386-win32 -Fii386 -FE. -FUi386/units/i386-win32
> -dRELEASE  -di386 -dGDB -dBROWSERLOG -Fux86 pp.pas
> pp.pas(210,1) Error: Entrypoint _mainCRTStartup not defined
> pp.pas(210,1) Fatal: There were 1 errors compiling module, stopping
> Fatal: Compilation aborted
> make[5]: *** [ppc386.exe] Error 1
> make[5]: Leaving directory `O:/Fpcsrc/compiler'
> make[4]: *** [next] Error 2
> make[4]: Leaving directory `O:/Fpcsrc/compiler'
> make[3]: *** [ppc1.exe] Error 2
> make[3]: Leaving directory `O:/Fpcsrc/compiler'
> make[2]: *** [cycle] Error 2
> make[2]: Leaving directory `O:/Fpcsrc/compiler'
> make[1]: *** [compiler_cycle] Error 2
> make[1]: Leaving directory `O:/Fpcsrc'
> make: *** [build-stamp.i386-win32] Error 2
> 
> 
> All happened after a clean...

Please ensure to use 2.0.4 as starting compiler.
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


[fpc-pascal] Resending: Trying to convert some C code

2006-11-07 Thread Ole J. Røtne

Hello again

My 5 year old kid did send this before I got it ready,
So here goes again..  


Would any FPC guru help me converting this C code? 
(it's from bn.h/libeay32.dll)
 
 
typedef struct bignum_st BIGNUM;
 
struct bignum_st
{
  BN_ULONG *d;
  int top;
  int dmax;
  int neg;
  int flags;
};

char *BN_bn2hex(const BIGNUM *a);
 
 
I guess my problem is understanding pointers, and how they work.
Tried something like this (did cut some checks & stuff to 
make it short):

Unit bn;

{$MODE DELPHI}{$H+}

interface

uses
  DynLibs;

type
  bignum_st = record
d:pointer;
dmax:integer;
neg:integer;
flag:integer;
  end;
  BIGNUM = bignum_st;
  
  BNPtr = ^BIGNUM;

var
  BnLibHandle: TLibHandle = 0;

function InitLib: Boolean;
function BN_Bn2Hex(const a:BNPtr):PChar;

implementation

Type
  TBN_bn2hex = function(a:BNPtr):PChar;

var
  _BnBn2Hex: TBN_bn2hex = nil;

function BN_Bn2Hex(a:BNPtr):PChar;
begin
_BnBn2Hex(a);
end;

Function InitLib:boolean;
Begin
  LibHandle := LoadLibrary('libeay32.dll');
  _BnBn2Hex := GetProcAddress( BnLibHandle, 'BN_bn2hex');
  result := true;
End;
End.


Left bits of the code out, and probably to much.
But I hope you get the idea..

(memo to self: never get coffe while kids are alone at comp)
 
Ole JR

___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] Resending: Trying to convert some C code

2006-11-07 Thread Henry Vermaak

i'm no guru, but here's a couple of things that you might try:

{$PACKRECORDS C} to make sure about that struct (gives me problems on
osx if i don't use it)


  BN_ULONG *d;

what is BN_ULONG?  make sure it's the same size of:

d:pointer;


you forgot the calling convention here:

Type
  TBN_bn2hex = function(a:BNPtr):PChar;

should have cdecl?


  LibHandle := LoadLibrary('libeay32.dll');
  _BnBn2Hex := GetProcAddress( BnLibHandle, 'BN_bn2hex');


i assume that LibHandle should be BnLibHandle?  what are the errors you get?

to get the general idea, see:
http://community.freepascal.org:1/docs-html/prog/progse53.html#x240-24300012.3

good luck
henry
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] Trying to convert some C code

2006-11-07 Thread Felipe Monteiro de Carvalho

since this is from a c library you should define {$packrecords c} on
the unit with this code.

type
 BIGNUM = bignum_st;

 PBIGNUM = ^bignum_st;

 bignum_st = record
   d: PBN_ULONG;
   top: cint;
   dmax: cint;
   neg: cint;
   flags: cint;
 end;

 TBN_bn2hex = function (const a: PBIGNUM): PChar; cdecl;

 As you can see this code won't compile, you need to also find the
declaration of BN_ULONG and define it. Also put ctypes on the uses
clause.

--
Felipe Monteiro de Carvalho
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] Resending: Trying to convert some C code

2006-11-07 Thread Henry Vermaak

another one:

function BN_Bn2Hex(a:BNPtr):PChar;
begin
  _BnBn2Hex(a);
end;


i also assume that it should be Result := _BnBn2Hex(a); ?  i don't
quite see the use of this function...

henry
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] Resending: Trying to convert some C code

2006-11-07 Thread Felipe Monteiro de Carvalho

ops .. only now I saw this.

You don't need to encapsulate the procedure variable inside a real
procedure. You can call a procedure variable, like if it was a
procedure.

Try this code:

Unit bn;

{$MODE DELPHI}{$H+}
{$packrecords c}

interface

uses ctypes, DynLibs;

type
 bignum_st = record
   d: pointer;
   dmax: cint;
   neg: cint;
   flag: cint;
 end;

 BIGNUM = bignum_st;

 PBIGNUM = ^BIGNUM;

 TBN_bn2hex = function (a: PBIGNUM): PChar; cdecl;

var
 BN_bn2hex: TBN_bn2hex;

function InitLib: Boolean;

implementation

Function InitLib: boolean;
Begin
 LibHandle := LoadLibrary('libeay32.dll');
 Pointer(BnBn2Hex) := GetProcAddress(LibHandle, 'BN_bn2hex');
 result := true;
End;

end.
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] Fpc compiler error win32 "Entrypoint _mainCRTStartup not defined"

2006-11-07 Thread Marius Ellen
Cool, just copying the old 2.0.4 ppc386.exe into the bin\i386-win32 
seems to be enough (or at least it compiles win32 and wince without any 
troubles now)


Thank you!
Marius

Florian Klaempfl wrote:


Please ensure to use 2.0.4 as starting compiler.




___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


SV: [fpc-pascal] Resending: Trying to convert some C code

2006-11-07 Thread Ole J. Røtne

Thanks for the replies

> -Opprinnelig melding-
> Fra: [EMAIL PROTECTED] 
> [mailto:[EMAIL PROTECTED] På vegne av 
> Henry Vermaak
> Sendt: 7. november 2006 12:19
> Til: FPC-Pascal users discussions
> Emne: Re: [fpc-pascal] Resending: Trying to convert some C code
> 
> i'm no guru, but here's a couple of things that you might try:
> 
> {$PACKRECORDS C} to make sure about that struct (gives me 
> problems on osx if i don't use it)

Ok, trying that.
 
> >   BN_ULONG *d;
> what is BN_ULONG?  make sure it's the same size of:
> > d:pointer;

BN_ULONG is just another way of saying unsigned long.
But redefined because it's C & for different compilers/platforms i think.

 
> you forgot the calling convention here:
> > Type
> >   TBN_bn2hex = function(a:BNPtr):PChar;
> should have cdecl?

Have it, but typing error :-S

 
> >   LibHandle := LoadLibrary('libeay32.dll');
> >   _BnBn2Hex := GetProcAddress( BnLibHandle, 'BN_bn2hex');
> 
> i assume that LibHandle should be BnLibHandle?  what are the 
> errors you get?

Yes it is.. Was typing this abit to fast after my kid sent the first before
i was done.

And my code does compile, but bomb with a unhandled exception when i use the
function.
That made me wonder if my parameters to the function was converted right..

As in, is this right "way" to convert parameter & return value..?

char *BN_bn2hex(const BIGNUM *a);

function BN_Bn2Hex(a:BNPtr):PChar; // here BNPtr is of type BNPtr:^BIGNUM


> to get the general idea, see:
> http://community.freepascal.org:1/docs-html/prog/progse53.
html#x240-24300012.3

Will take a look..

Ole JR

___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


SV: [fpc-pascal] Resending: Trying to convert some C code

2006-11-07 Thread Ole J. Røtne


Will try this to , thanks for the tip :)

> -Opprinnelig melding-
> Fra: [EMAIL PROTECTED] 
> [mailto:[EMAIL PROTECTED] På vegne av 
> Felipe Monteiro de Carvalho
> Sendt: 7. november 2006 12:42
> Til: FPC-Pascal users discussions
> Emne: Re: [fpc-pascal] Resending: Trying to convert some C code
> 
> ops .. only now I saw this.
> 
> You don't need to encapsulate the procedure variable inside a 
> real procedure. You can call a procedure variable, like if it 
> was a procedure.
> 
> Try this code:
> Unit bn;
> 
> {$MODE DELPHI}{$H+}
> {$packrecords c}
> 
> interface
> 
> uses ctypes, DynLibs;
> 
> type
>   bignum_st = record
> d: pointer;
> dmax: cint;
> neg: cint;
> flag: cint;
>   end;
> 
>   BIGNUM = bignum_st;
> 
>   PBIGNUM = ^BIGNUM;
> 
>   TBN_bn2hex = function (a: PBIGNUM): PChar; cdecl;
> 
> var
>   BN_bn2hex: TBN_bn2hex;
> 
> function InitLib: Boolean;
> 
> implementation
> 
> Function InitLib: boolean;
> Begin
>   LibHandle := LoadLibrary('libeay32.dll');
>   Pointer(BnBn2Hex) := GetProcAddress(LibHandle, 'BN_bn2hex');
>   result := true;
> End;
> 
> end.
> ___
> fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org 
> http://lists.freepascal.org/mailman/listinfo/fpc-pascal
> 
> 

___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] Resending: Trying to convert some C code

2006-11-07 Thread Henry Vermaak

BN_ULONG is just another way of saying unsigned long.
But redefined because it's C & for different compilers/platforms i think.


in that case, use d: PCardinal or pcULong (in ctypes - probably better)



As in, is this right "way" to convert parameter & return value..?
char *BN_bn2hex(const BIGNUM *a);
function BN_Bn2Hex(a:BNPtr):PChar; // here BNPtr is of type BNPtr:^BIGNUM


that looks o.k.  rather use "const a:BNPtr", though.

henry
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


SV: [fpc-pascal] Resending: Trying to convert some C code

2006-11-07 Thread Ole J. Røtne

> -Opprinnelig melding-
> Fra: [EMAIL PROTECTED] 
> [mailto:[EMAIL PROTECTED] På vegne av 
> Henry Vermaak
> Sendt: 7. november 2006 15:04
> Til: FPC-Pascal users discussions
> Emne: Re: [fpc-pascal] Resending: Trying to convert some C code
> 
> >BN_ULONG is just another way of saying unsigned long.
> >But redefined because it's C & for different 
> compilers/platforms i think.
> 
> in that case, use d: PCardinal or pcULong (in ctypes - 
> probably better)

Ah. Will do :)

> 
> >As in, is this right "way" to convert parameter & return value..?
> >char *BN_bn2hex(const BIGNUM *a);
> >function BN_Bn2Hex(a:BNPtr):PChar; // here BNPtr is of type 
> >BNPtr:^BIGNUM
> 
> that looks o.k.  rather use "const a:BNPtr", though.

Done that, and got it working too :)


Anyway, got it working thanks to you & Felipe. 


So a big thank-you to you both.


Ole JR 

___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] Trying to convert some C code

2006-11-07 Thread Florian Klaempfl
Please don't start new topis by replying to another one. This makes reading
mails in the tree view very confusing.
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal