Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / fpc-pascal / 2006-11

Fpc compiler error win32 "Entrypoint _mainCRTStartup not defined"

14 messages · 6 people ·

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

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

Reply by email

Ole J. Røtne
to Marius

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

Reply by email

Florian Klaempfl
to Marius: Was trying the last trunk and got this error on the i386-win32. Its not a big deal, we…
Show quoted text 30 lines
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.

Reply by email

Ole J. Røtne
to Marius: Was trying the last trunk and got this error on the i386-win32. Its not a big deal, we…

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

Reply by email

Henry Vermaak
to Ole J. Røtne

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:10000/docs-html/prog/progse53.html#x240-24300012.3

good luck
henry

Reply by email

Felipe Monteiro de Carvalho
to Ole J. Røtne: Hello Would any FPC guru help me converting this C code? (it's from bn.h/libeay32.dll)…

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

Reply by email

Felipe Monteiro de Carvalho
to Ole J. Røtne: Hello again My 5 year old kid did send this before I got it ready, So here goes again..…

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.

Reply by email

Ole J. Røtne
to Henry Vermaak: i'm no guru, but here's a couple of things that you might try: {$PACKRECORDS C} to make…

Thanks for the replies

Show quoted text 12 lines
-----Opprinnelig melding----- Fra: 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

Show quoted text 5 lines
> 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

html#x240-24300012.3

Will take a look..

Ole JR

Reply by email

Ole J. Røtne
to Felipe Monteiro de Carvalho: ops .. only now I saw this. You don't need to encapsulate the procedure variable inside a…

Will try this to , thanks for the tip :)

Show quoted text 58 lines
-----Opprinnelig melding----- Fra: 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 - http://lists.freepascal.org/mailman/listinfo/fpc-pascal

Reply by email

Henry Vermaak
to Ole J. Røtne
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

Reply by email

Ole J. Røtne
to Henry Vermaak
Show quoted text 14 lines
-----Opprinnelig melding----- Fra: 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 :)

Show quoted text 7 lines
>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

Reply by email