Re: [fpc-pascal] Compile library with Linux
Florian Klaempfl a écrit : Michel Meunier schrieb: Florian Klaempfl a écrit : Michel Meunier schrieb: Hello, My library under Windows is now OK, it use an UDP socket with the Synapse units (wonderful job). Now I want to compile it under Linux. The compilation is OK, but when I try to use the .so library, I get this message: This binary has no thread support compiled in. Recompile the application with a thread-driver in the program uses clause before other units using thread. Runtime error 232 at $B6A4418B I use a thread inside the code to survey the UDP socket, it's work very well with Windows, but do you know where is the problem with Linux? Well, do as the message say and add the cthreads unit. This is not done by default because it causes libc dependencies. Ok, if I understand, I have to add cthreads in the Uses part. But why can I compile a program witch use threads without any error when an unit is missing? Because the threading interface is plugable and FPC provides a dummy driver by default. Is it specific to Linux, or also available with Windows. My dll seams to work properly uner windows, and it uses a thread. Thanks a lot for your help. ___ 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 -- Michel Meunier Web: www.etoiles-a-bleau.fr ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] Compile library with Linux
Florian Klaempfl a écrit : Michel Meunier schrieb: Hello, My library under Windows is now OK, it use an UDP socket with the Synapse units (wonderful job). Now I want to compile it under Linux. The compilation is OK, but when I try to use the .so library, I get this message: This binary has no thread support compiled in. Recompile the application with a thread-driver in the program uses clause before other units using thread. Runtime error 232 at $B6A4418B I use a thread inside the code to survey the UDP socket, it's work very well with Windows, but do you know where is the problem with Linux? Well, do as the message say and add the cthreads unit. This is not done by default because it causes libc dependencies. Correction of the previous message: Ok, if I understand, I have to add cthreads in the Uses part. But why can I compile a program witch use threads without any error when an unit is missing? Thanks a lot for your help. ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal -- Michel Meunier Web: www.etoiles-a-bleau.fr ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] Compile library with Linux
Florian Klaempfl a écrit : Michel Meunier schrieb: Hello, My library under Windows is now OK, it use an UDP socket with the Synapse units (wonderful job). Now I want to compile it under Linux. The compilation is OK, but when I try to use the .so library, I get this message: This binary has no thread support compiled in. Recompile the application with a thread-driver in the program uses clause before other units using thread. Runtime error 232 at $B6A4418B I use a thread inside the code to survey the UDP socket, it's work very well with Windows, but do you know where is the problem with Linux? Well, do as the message say and add the cthreads unit. This is not done by default because it causes libc dependencies. Ok, if I understand, I have to add cthreads in the Uses part. But why can I compile a program witch use threads without any error when an unit is missing? Thanks a lot for your help. ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal -- Michel Meunier Web: www.etoiles-a-bleau.fr ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal
[fpc-pascal] Compile library with Linux
Hello, My library under Windows is now OK, it use an UDP socket with the Synapse units (wonderful job). Now I want to compile it under Linux. The compilation is OK, but when I try to use the .so library, I get this message: This binary has no thread support compiled in. Recompile the application with a thread-driver in the program uses clause before other units using thread. Runtime error 232 at $B6A4418B I use a thread inside the code to survey the UDP socket, it's work very well with Windows, but do you know where is the problem with Linux? Best Regards Michel Meunier ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] Windows-->Linux library
Leducq Dominique a écrit : Le Mercredi 14 Février 2007 09:19, Michel Meunier a écrit : Hello, With your help, my initial library .dll writen with Delphi, is now working at about 95% when compiled with fpc. Now my goal is to get a .so library under Linux. So I have begun to compile it under linux. There are a lot of hints but not important, but after I have this message: Error: Util -as not found, switching to external linking Was does it mean? Have you the binutils package installed ? Also a strange thing, to launch lazarus, I have to use this command: sudo /usr/share/startlazarus, there is nothing in the /usr/bin directorie. I have installed Lazarus and FPC with .deb files in my Kubuntu. But it's not an important problem, the main problem is my unhability to compile my library. Best regards ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal Thanks for your help. In fact as the project had been save under windows, the compile options were for Windows. So the compilation begins very well.Now I have a lot of problem because the library open a socket and establish a link with the UDP standard. The fonctions use to manage sockets under Linux and Windows are different. So I have to add directive of compilation to work under windows or linux. A lot of work. -- Michel Meunier www.etoiles-a-bleau.fr ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal
[fpc-pascal] Windows-->Linux library
Hello, With your help, my initial library .dll writen with Delphi, is now working at about 95% when compiled with fpc. Now my goal is to get a .so library under Linux. So I have begun to compile it under linux. There are a lot of hints but not important, but after I have this message: Error: Util -as not found, switching to external linking Was does it mean? Also a strange thing, to launch lazarus, I have to use this command: sudo /usr/share/startlazarus, there is nothing in the /usr/bin directorie. I have installed Lazarus and FPC with .deb files in my Kubuntu. But it's not an important problem, the main problem is my unhability to compile my library. Best regards -- Michel Meunier Web: www.etoiles-a-bleau.fr ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal
[fpc-pascal] How to get UTC time
Hello, I work on a program wich need the UTC time, and this program will run with Windows and Linux. So how is it possible to calculate the UTC time under these two OS. For example, the Now function with Windows, give me local time. Best regards -- Michel Meunier Web: www.etoiles-a-bleau.fr ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] dll with windows impossible???
Bisma Jayadi a écrit : Absolutly NO, but my problem is to have a reliable compiler to work properly, not to run after strange problems. It's completely non sense to blame your compiler before do some deep investigations upon your problem. Many people have used FPC to build dynamic libraries without problems and work perfectly, both console or GUI program. It could be caused by your own mistake! That's right, but as you can see, it's a problem with the option -gl. -Bee- has Bee.ography at: http://beeography.wordpress.com ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal -- Michel Meunier Web: www.etoiles-a-bleau.fr ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] dll with windows impossible???
Michael Van Canneyt a écrit : On Wed, 24 Jan 2007, Michel Meunier wrote: Michael Van Canneyt a écrit : On Wed, 24 Jan 2007, Michel Meunier wrote: [cut code] xxx and IT DOESN'T WORK, why? It is exactly the same code! More and more I think I am going to translate my code in C, because FPC seems unable to manage properly dll library. It has nothing to do with FPC. 1. Compile the DLL without debug info. (lazarus compiles it by default with debug info included. Disable that) it's the case 2. ALWAYS specify the complete path to the DLL. Do NOT assume that the program is started with as the current directory the program directory. This is a common mistake. Ok, I have tried, and the problem is the same :-( 1. What is the return value of LoadLibrary ? Have you checked it ? the return value is 0 2. If it is <>0 immediatly get the last error: raiselastoserror. This should give you at least a hint why windows thinks it can't load your library. when I make a test with Lazarus, I get this message: project raises exception class 'External: SIGSEGV' and next, in another window: execution stopped Adress: $7C92E183 procedure: ntdll!LdrFindRessource_U File: And I have also replaced my 'testdll.dll' by a dll compiled with Delphi and next renamed 'testdll.dll', and it's ok, so the problem is with the library compile with FPC. 3. Did you specify $APPTYPE GUI in the library as well ? If not, do so. Otherwise the library will try to initialize the terminal, when it cannot: there is none, since the loading program does not have one! I have added: {$APPTYPE GUI} just after 'library dlltest;' in the code and no change. 4. You can also try vice versa: specify apptype console in your GUI program. The GUI will still run, but in addition a terminal will be opened, allowing the library to initialize it. I have added: {$APPTYPE CONSOLE} in the GUI program to test the dll, and no change. Can you test all this, please ? Michael. OUPS, i have found the solution, in the linking part, the option -gl was set, it's difficult to translate in english, but it's to insert the number of lines in case of debug. And now it's working!! Whaou, thanks a lot for your help. -- Michel Meunier Web: www.etoiles-a-bleau.fr ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] dll with windows impossible???
Michael Van Canneyt a écrit : On Wed, 24 Jan 2007, Michel Meunier wrote: [cut code] xxx and IT DOESN'T WORK, why? It is exactly the same code! More and more I think I am going to translate my code in C, because FPC seems unable to manage properly dll library. It has nothing to do with FPC. 1. Compile the DLL without debug info. (lazarus compiles it by default with debug info included. Disable that) it's the case 2. ALWAYS specify the complete path to the DLL. Do NOT assume that the program is started with as the current directory the program directory. This is a common mistake. Ok, I have tried, and the problem is the same :-( If you are still experiencing problems after that, mail me in private. Michael. ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal -- Michel Meunier www.etoiles-a-bleau.fr ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] dll with windows impossible???
Felipe Monteiro de Carvalho a écrit : Another relevant question: on which directory and how did you install lazarus/fpc? d:\lazarus, without any space Installing on directories with spaces can have nasty effects on the gnu tools. -- Michel Meunier www.etoiles-a-bleau.fr ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] dll with windows impossible???
Flávio Etrusco a écrit : I am trying again without any hope, to use dll in a wondows application. (...) More and more I think I am going to translate my code in C, because FPC seems unable to manage properly dll library. Thanks for your help. Do you think whining and shouting "I will turn to C" will get you better replies than otherwise? Absolutly NO, but my problem is to have a reliable compiler to work properly, not to run after strange problems. Regards, Flávio ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal -- Michel Meunier www.etoiles-a-bleau.fr ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] dll with windows impossible???
Felipe Monteiro de Carvalho a écrit : I tested here and everything worked fine on the Application with a Form. Further, I´ve written dozens of DLLs with Free Pascal and all worked fine. My guess is that there is something wrong with your Setup. What Windows version are you using? Windows XP with SP2 What FPC and Lazarus versions are you using? Lazarus-0.9.20 fpc-2.0.4-20061105 the latest stable version. Maybe your download was slightly corrupted, you could try to remove your fpc / lazarus install and do a free install with the latest *stable* version. Or else, you should try the obvious. Is the DLL on the same folder as the executable? yes of course How are you executing the application? inside Lazarus, and also outside Lazarus Best regards -- Michel Meunier www.etoiles-a-bleau.fr ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal
[fpc-pascal] dll with windows impossible???
Hello, I am trying again without any hope, to use dll in a wondows application. It's very strange it's working with console application but not with windows apllication. My dll code is very very simple: library dlltest; {$mode objfpc}{$H+} uses Classes { add your units here }; function test ( ) : integer ; stdcall ; begin test:=1; end ; exports test ; end . next the console program wich is working, very simple: program testdll; {$mode objfpc}{$H+} uses {$IFDEF UNIX}{$IFDEF UseCThreads} cthreads, {$ENDIF}{$ENDIF} Classes,dynlibs { add your units here }; var handledll:integer; begin handledll:=loadlibrary('dlltest.dll'); if handledll=0 then writeln('raté') else writeln('OK'); writeln(handledll); end. x now the windows program: main part: xxx program testdllwindows; {$mode objfpc}{$H+} uses {$IFDEF UNIX}{$IFDEF UseCThreads} cthreads, {$ENDIF}{$ENDIF} Interfaces, // this includes the LCL widgetset Forms { add your units here }, testdllwin; begin Application.Initialize; Application.CreateForm(TForm1, Form1); Application.Run; end. xxx and the unit: unit testdllwin; {$mode objfpc}{$H+} interface uses Classes, SysUtils, LResources, Forms, Controls, Graphics, Dialogs, Buttons,dynlibs; type { TForm1 } TForm1 = class(TForm) Button1: TButton; procedure Button1Click(Sender: TObject); private { private declarations } public { public declarations } end; var Form1: TForm1; implementation { TForm1 } procedure TForm1.Button1Click(Sender: TObject); var handledll:integer; begin handledll:=loadlibrary('dlltest.dll'); if handledll=0 then showmessage('raté') else showmessage('OK'); end; initialization {$I testdllwin.lrs} end. xxx and IT DOESN'T WORK, why? It is exactly the same code! More and more I think I am going to translate my code in C, because FPC seems unable to manage properly dll library. Thanks for your help. Michel -- Michel Meunier Web: www.etoiles-a-bleau.fr ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] Becoming crazy with dll
The error message with loadlibrary is: external: SIGSEGV thanks -- Michel Meunier Web: www.etoiles-a-bleau.fr ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] Becoming crazy with dll
I hope, I haven't made an error to get such messages! -- Michel Meunier Web: www.etoiles-a-bleau.fr ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal
[fpc-pascal] Becoming crazy with dll
Hello, I try to translate a dll from delphi to fpc, but I have a lot of problem. First I am unable to load it with loadlibrary. the code of the library is: x library dlltest; {$mode objfpc}{$H+} uses Classes { add your units here }, dlltestUnit; exports AskForExecuteCCDCommand name 'AskForExecuteCCDCommand'; begin end. xxx and the unit associate is: unit dlltestUnit; {$mode objfpc}{$H+} interface uses Classes, SysUtils; const MaxCommand=100; type // Param structures that is used to pass the data // 32 bits Alignement TParamCCD = record NbreParam: Integer; Param: array[0..MaxCommand - 1] of Pchar; end; PParamCCD = ^TParamCCD; // Pointer procedure AskForExecuteCCDCommand(ParamCCDInt, ParamCCDOut: PParamCCD); stdcall; // C-C++ calling conventions implementation procedure AskForExecuteCCDCommand(ParamCCDInt, ParamCCDOut: PParamCCD); stdcall; // C-C++ calling conventions begin end; end. xxx next in a small programm I try to load the library, but the handle is allways 0. The part with the code is: x Var HandleDLL:Integer; begin HandleDLL := LoadLibrary('dlltest.dll'); if HandleDLL <> 0 then begin showmessage('ok'); showmessage(inttostr(HandleDLL)); end xxx Thanks a loy for your help, I am becoming crazy with that! -- Michel Meunier Web: www.etoiles-a-bleau.fr ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal