[fpc-pascal] Compiling library / Win32 DLL

2005-12-29 Thread chromdildo
Hallo list.

I'm having trouble with library/DLL under Win32 (exporting one function
and having a little GUI).
Compiles fine, but the host application can't load them. The Host is
closed source (think MSVC).

Same code compiles and runs fine with Delphi.

Can someone describe the main differences with building/linking
libraries under Delphi/freepascal.
I'm sure I'm missing some compiler/linker - switch.

Thank you very much
chrom

P.S. Merry Xmas and happy new year to all.

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


Re: [fpc-pascal] Quake 2 for Freepascal

2005-12-29 Thread Jonas Maebe


On 29 Dec 2005, at 04:27, L505 wrote:

Seems FPC always has graphics related issues for some reason when  
compiling Delphi
code - I've not had problems with FPC/Delphi compatability when  
working with text,

since I mainly work with text programs and not graphics.


There's no inherent difference between "graphics" and "text" code. It  
simply means that there is a bug somewhere, either in the code  
generator or in the Windows-related units.



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


[fpc-pascal] Problem with FPC2.0.2 and windows

2005-12-29 Thread Hans Mårtensson
I decided to improve an old program, I had written for windows, using 
FreePascal 1.0.10.
Having downloaded FPC 2.0.2, I wanted to use this version, believing 
that the newer is the better.
So I tried to recompile my old source code with 2.0.2, getting a lot of 
compile errors.
Anyhow, all of them could be tracked down to 3 problems with call of 
procedures in the windows unit, and the two of them could easily be 
repaired. But I have problems with the last one.


The problem was the following program line, using the windows unit:
if DialogBoxIndirect(0, pBox2, Window, @Box2Proc) = 0 then exit;
The compiler assessed an error in parameter 4. Should not be an address, 
but a variable.


So I tried:
if DialogBoxIndirect(0, pBox2, Window, Box2Proc) = 0 then exit;
And the compiler assessed that the number of parameters was wrong.
But this is an error in message, because the number of parameters is right.

Then I tried to define a procedural type TBoxproc and then declared a 
variable:

var BoxProc: TBoxproc;

and changed my program to:
BoxProc:[EMAIL PROTECTED];
if DialogBoxIndirect(0, pBox2, Window, BoxProc)=0 then exit;

Now FPC compiled my program to the end.

BUT following problems remains:
1) I don’t understand why it should be necessary to use a variable that 
is assigned to @Box2Proc, in stead of using @Box2Proc directly as the 
parameter.


2) Even though the compiler produces an exe file, this does not work. 
The call of DialogBoxIndirect does not produce any dialogue box, but 
returns having done nothing. Now it is a bit tricky to make this 
dialogue box business work, because pBox2 must point to a data 
structure, and if there are errors in this data structure, windows do 
not produce any error message. But in this case, my data structure 
worked with the old version of FPC. I have tried to compile exactly the 
same source files with compiler 1.0.10 and with 2.0.2. The first program 
worked all right, but the second did not show any dialogue box, when the 
procedure in question was invoked.


So I suspect that the compiler or the windows unit that comes with the 
2.0.2 version has some error.

Does anybody know about these problems?

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


[fpc-pascal] license for FreePascal Documentation

2005-12-29 Thread Aleksey Ulasevich

I can't find license for FreePascal documentation. Where I can get it?
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] Compiling library / Win32 DLL

2005-12-29 Thread Иван Шихалев
> Same code compiles and runs fine with Delphi.

May be a troubles with export names. It is needed to define export
names explicite in "exports" clause.
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] license for FreePascal Documentation

2005-12-29 Thread Florian Klaempfl
Aleksey Ulasevich wrote:

> I can't find license for FreePascal documentation. Where I can get it?

See sources of the docs e.g.
http://svn.freepascal.org/svn/fpcdocs/trunk/user.tex

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


Re: [fpc-pascal] Compiling library / Win32 DLL

2005-12-29 Thread Tony Pelton
you are using FP or its IDE and _not_ lazarus ... right ?

i had some troubles with building a DLL with lazarus, where identical
code would build link under lazarus, and my windows application
wouldn't load it, and everything would work fine when i built it using
the FP compiler standalone.

likely a user error, but i was never able to figure it out.

my $0.02

Tony

On 12/29/05, chromdildo <[EMAIL PROTECTED]> wrote:
> Hallo list.
>
> I'm having trouble with library/DLL under Win32 (exporting one function
> and having a little GUI).
> Compiles fine, but the host application can't load them. The Host is
> closed source (think MSVC).
>
> Same code compiles and runs fine with Delphi.
>
> Can someone describe the main differences with building/linking
> libraries under Delphi/freepascal.
> I'm sure I'm missing some compiler/linker - switch.
>
> Thank you very much
> chrom
>
> P.S. Merry Xmas and happy new year to all.
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] Compiling library / Win32 DLL

2005-12-29 Thread chromdildo
Thanks for your reply.

Whats the difference, when compiling without Lazarus?
The library relys on the LCL (for GUI) and compiling from commandline
results in exactly the same (non working) dll.
Where can I learn more about the structures, calling conventions, etc
used by freepascal/Lazarus vs. Delphi?

Thanks again and best regards.
chrom


This code(-snippet) compiled with Delphi works perfect (from
www.tobybear.de (GPL))

[code]
{$J-,H+,T-P+,X+,B-,V-,O+,A+,W-,U-,R-,I-,Q-,D-,L-,Y-,C-}
library VstPlugin;
uses
  uPlugin in 'uPlugin.pas',
  uEditor in 'uEditor.pas' {PluginEditorWindow},
  DAEffect;
var Effect : APlugin;
Oome   : Boolean;
function main(audioMaster: TAudioMasterCallbackFunc): PAEffect; cdecl;
export;
begin
 // get vst version
 if audioMaster(nil, audioMasterVersion, 0, 0, nil, 0) = 0 then
 begin
  Result := nil;
  Exit;
 end;
 Effect := APlugin.Create(audioMaster);
 if not Assigned(Effect) then
 begin
  Result := nil;
  Exit;
 end;
 if oome then
 begin
  Effect.Free;
  Result := nil;
  Exit;
 end;
 Result := Effect.Effect;
end;

exports
Main name 'main';

begin
end.
[/code]




Tony Pelton wrote:

>you are using FP or its IDE and _not_ lazarus ... right ?
>
>i had some troubles with building a DLL with lazarus, where identical
>code would build link under lazarus, and my windows application
>wouldn't load it, and everything would work fine when i built it using
>the FP compiler standalone.
>
>likely a user error, but i was never able to figure it out.
>
>my $0.02
>
>Tony
>
>On 12/29/05, chromdildo <[EMAIL PROTECTED]> wrote:
>  
>
>>Hallo list.
>>
>>I'm having trouble with library/DLL under Win32 (exporting one function
>>and having a little GUI).
>>Compiles fine, but the host application can't load them. The Host is
>>closed source (think MSVC).
>>
>>Same code compiles and runs fine with Delphi.
>>
>>Can someone describe the main differences with building/linking
>>libraries under Delphi/freepascal.
>>I'm sure I'm missing some compiler/linker - switch.
>>
>>Thank you very much
>>chrom
>>
>>P.S. Merry Xmas and happy new year to all.
>>
>>
>___
>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] Compiling library / Win32 DLL

2005-12-29 Thread Tony Pelton
On 12/29/05, chromdildo <[EMAIL PROTECTED]> wrote:
> Thanks for your reply.
>
> Whats the difference, when compiling without Lazarus?

i don't know.

i just wanted to mention it, in case it was relevant.

i had started doing development using the FP console IDE.

i then "discovered" Lazarus, and wanting to be able to use a GUI IDE,
i downloaded and installed it.

i then took the exact same code, compiled it, which produced a DLL for
me, and when i tried to get my hosting application to load it, it
complained, saying it wasn't a DLL.

i then loaded the FP IDE, recompiled the same code, and it went back to working.

i posted to the list, asking questions about my problem, but no one
seemed to know why i might be having the problem.

someone even sent me a "dll loader" tool to test whether my DLL would
load with their testing tool.

the DLL _did_ load with the tool, but the application i was using
still wouldn't deal with it, until i recompiled it with the FP console
IDE.

since then, i've just stayed with the console IDE/compiler and i
haven't had any issues.

just as another thought ... because i recently had a problem that
really messed me up for a couple of hours.

i had installed the newer 2.0.2 compiler, after having used the 2.0.1
compiler on my windows machine for a while.

i then loaded up some of my source, and went about doing more
development on 2.0.2.

when i started testing some of my latest code changes, as a DLL within
another application, i was getting ALL KINDS of crazy behavior.

no crashes, just really bizzare behavior from some of the API calls i
was using for my third party application.

stuff that is really hard to explain in any detail in an e-mail ...
but things like "enumerators" within the API suddenly stopped
enumerating ... without error ... function calls that returned enums
were returning the wrong enum value ... stuff like that.

after alot of head scratching and poking and prodding ... i ended up
cleaning up a bunch of "dot o" files from some of the units for the
third party API wrappers that are implemented in pascal, and which
were being compiled by FP.

my problems went away.

some kind of weird issue between 2.0.1 and 2.0.2 in the object files.

i'm not sure if this would be considred "unexpected" ... but at the
time it just didn't occur to me.

so ... make sure you are building all your code, and dependent source
code "clean".

$0.02

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


Re: [fpc-pascal] Quake 2 for Freepascal

2005-12-29 Thread L505

- Original Message -
From: "Jonas Maebe" <[EMAIL PROTECTED]>
To: "FPC-Pascal users discussions" 
Sent: Thursday, December 29, 2005 2:07 AM
Subject: Re: [fpc-pascal] Quake 2 for Freepascal


>
> On 29 Dec 2005, at 04:27, L505 wrote:
>
> > Seems FPC always has graphics related issues for some reason when
> > compiling Delphi
> > code - I've not had problems with FPC/Delphi compatability when
> > working with text,
> > since I mainly work with text programs and not graphics.
>
> There's no inherent difference between "graphics" and "text" code. It
> simply means that there is a bug somewhere, either in the code
> generator or in the Windows-related units.
>
>
> Jonas

Right, I hope it is maybe something simple in the Windows related units which is
being called over and over again.. If anyone is interested I can post the Quake 
2
freepascal port up online. I'm working on other things at the moment so don't 
have
much time to peak at the moment..

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


Re: [fpc-pascal] Quake 2 for Freepascal

2005-12-29 Thread Tony Pelton
On 12/29/05, L505 <[EMAIL PROTECTED]> wrote:
> If anyone is interested I can post the Quake 2 freepascal port up online.

i'm interested in looking at the code from an academic perspective.

please do post.

i could even help mirror it if need be.

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


Re: [fpc-pascal] Compiling library / Win32 DLL

2005-12-29 Thread L505



>i had started doing development using the FP console IDE.
>
>i then "discovered" Lazarus, and wanting to be able to use a GUI IDE,
>
>i downloaded and installed it.
>
>i then took the exact same code, compiled it, which produced a DLL for
>me, and when i tried to get my hosting application to load it, it
>complained, saying it wasn't a DLL.
>
>i then loaded the FP IDE, recompiled the same code, and it went back to 
>working.
>
>i posted to the list, asking questions about my problem, but no one
>seemed to know why i might be having the problem.

>someone even sent me a "dll loader" tool to test whether my DLL would
>load with their testing tool.

I had sent you that tool, and it was extremely simple but it has solved some 
problems
I've had before.  I recalled having the same problem as you, once with lazarus..
lazarus didn't create a good DLL for me but for some reason my problem went away
after a while, and lazarus was producing OKAY dll's. I should have written down 
what
if anything I found out?? One of my issues was smart linking. The compiler did 
not
generate good DLL's when you had the smart linking on. But this was later 
repaired by
someone.. And again, it may not have to do with your issue. I am just guessing 
maybe
you had smartlinking on in lazarus, but not in the FP ide. Or maybe the FP Ide 
was a
different version of compiler than your compiler included with Lazarus in 
/pp/bin/

>the DLL _did_ load with the tool, but the application i was using
>still wouldn't deal with it, until i recompiled it with the FP console
>IDE.

Since the IDE has it's own compiled in compiler, maybe the compiler that was 
compiled
in was a different version than the one you were using with Laz? If you have 
time,
try pointing lazarus to use the exact same version of compiler that the FP IDE 
was
using (in environment options).

>stuff that is really hard to explain in any detail in an e-mail ...
>but things like "enumerators" within the API suddenly stopped
>enumerating ... without error ... function calls that returned enums
>were returning the wrong enum value ... stuff like that.


>after alot of head scratching and poking and prodding ... i ended up
>cleaning up a bunch of "dot o" files from some of the units for the
>third party API wrappers that are implemented in pascal, and which
>were being compiled by FP.
>
>my problems went away.

I've had the FPC config file problem before, where FPC config file is 
referencing my
old FPC units in other directories. It will pick up old .PPU/.o/.a files 
especially
if the FPC.CFG file has not updated the -FuC:\wherever\ to the new directories.
It's not actually in FPC config file problem as much as it is a user error 
problem
(my fault, really, for not updating the FPC cfg file in all the directories - 
the
problem is when you have two or more compilers running on one system)

> some kind of weird issue between 2.0.1 and 2.0.2 in the object files.

They are simply generated from the compiler with the PPU files, so if you use 
2.0.0
.o files with 2.0.2 ppu files this will definitely cause issues AFAIK, and I've 
had
this problem before when the FPC.CFG file is pointing to old directories, as 
far as I
can remember.


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


Re: [fpc-pascal] Quake 2 for Freepascal

2005-12-29 Thread L505

> If anyone is interested I can post the Quake 2 freepascal port up online.

>> i'm interested in looking at the code from an academic perspective.
>>
>> please do post.
>>
>> i could even help mirror it if need be.


http://z505.com/cgi-bin/qkcont/qkcont.cgi?p=Quake2FreePascal

Remember everyone, to read instructions.. if you don't, you will get an error 
saying
"software refresh blah blah" because the Quake PAK file is missing (similar to 
a doom
WAD file).

--
L505

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