Error while linking lazarus / 1-Linux ---------------------------------------------------------------------- ezkiellg · 2010-05-02 04:34 Hello! I am Brazilian, sorry if I write something wrong. My computer broked and I'm tired of Windows. So I using OpenSuSE 11.2 in an Acer AspireOne D250 temporally. I develop systems and want to use Lazarus, but I'm having problems with libraries. When compiling, Lazarus says: "/usr/bin/ld: warning: /home/ezequiel/Documents/Material/Projetos/Book man_Comercial/Linux/link.res contains output sections; did you forget -T? /usr/bin/ld: cannot find -lfbookman bookman.lpr(22,1) Error: Error while linking bookman.lpr(22,1) Fatal: There were 1 errors compiling module, stopping" One method used to call functions in the library: "function ValidaEmail(email: string): string; cdecl; external 'fbookman.so'; function ValidaCPF(cpf: string): string; cdecl; external 'fbookman.so';" I also read the topic "http://www.freepascal.com.br/viewtopic.php?t=27 8&sid=a3bdcfc6aa1f769eee4e6021e02d2336" but not work yet. The Lazarus's version is 0.9.28.2 beta and FreePascal version is 2.2.4. Please, Can anyone help me? I really want to work only with Linux, so I need to learn Lazarus's methods. Thanks! Source-code of a basic project: LPR File content: "program bookman; {$mode objfpc}{$H+} uses   {$IFDEF UNIX}{$IFDEF UseCThreads}   cthreads,   {$ENDIF}{$ENDIF}   Forms, UntPrincipal, LResources, Interfaces; // {$IFDEF WINDOWS}{$R bookman.rc}{$ENDIF} {$IFDEF WINDOWS}{$R bookman.rc}{$ENDIF} begin   {$I bookman.lrs}   Application.Title:='Bookman'; //  {$I bookman.lrs}   Application.Initialize;   Application.CreateForm(TForm1, Form1);   Application.Run; end." Unit content: "unit UntPrincipal; {$mode objfpc}{$H+} {$ifdef unix} {$endif} interface uses   dl, SysUtils, LResources, Forms, StdCtrls, Classes, Dialogs; type   { TForm1 }   TForm1 = class(TForm)     Button1: TButton;     Edit1: TEdit;     procedure Button1Click(Sender: TObject);   private     { private declarations }   public     { public declarations }   end; var   Form1: TForm1; function ValidaEmail(email: string): string; cdecl; external 'fbookman.so'; function ValidaCPF(cpf: string): string; cdecl; external 'fbookman.so'; implementation { TForm1 } procedure TForm1.Button1Click(Sender: TObject); begin   ShowMessage(ValidaCPF(Edit1.Text)); end; initialization   {$I UntPrincipal.lrs} end." Library source-code: "library fbookman; {$mode objfpc}{$H+} uses   Classes, SysUtils, StrUtils; function ValidaEmail(email: string): string; {$ifndef linux} stdcall; {$else} cdecl; {$endif} export;   var     c, caraci, qtpontosf, qtarrobas, posarroba, tamanho: integer;   begin //#000     //Application.Initialize;     tamanho:=length(email);     posarroba:=(-1);     qtarrobas:=0; qtpontosf:=0; c:=1; caraci:=0;     if tamanho<8       then begin //#002         result:='E-mail inválido!';       end //#002       else begin //#003         while c<=tamanho do begin //#001           case (1+AnsiIndexStr(email[c],['@','.','- ','_','a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p', 'q','r','s','t','u','v','w','x','y','z','0','1','2','3','4','5','6','7 ','8','9'])) of //#007             1: begin //#005                  if qtarrobas>0                    then begin //#008                      result:='E-mail inválido!';                      c:=tamanho;                    end //#008                    else begin //#007                      qtarrobas:=1;                      posarroba:=c;                    end; //#007                end; //#005             2: begin //#006                  if ((qtarrobas>0) and (c-posarroba<3)) or ((email[c-1]='.') or (email[c+1]='.') or (email[c-1]='@') or (email[c+1]='@') or (tamanho-c<2) or (c=1))                    then begin //#009                      result:='E-mail inválido!';                      c:=tamanho;                    end; //#009                    if c>posarroba                      then qtpontosf:=qtpontosf+1;                end; //#006             3..40: if qtarrobas=0                      then caraci:=caraci+1;             else begin //#004               result:='xx E-mail inválido! xx';               if c<>tamanho                 then c:=tamanho;             end; //#004           end; //#007           c:=c+1;         end; //#001       end; //#003       if (qtarrobas<>1) or (qtpontosf<1) or (caraci<2)         then result:='E-mail inválido!'         else if result=''           then result:='Ok';   end; //#000 function ValidaCPF(cpf: string): string; {$ifndef linux} stdcall; {$else} cdecl; {$endif} export;   var     c, d1, d2, total: integer;     ncpf: string;   begin //#000     //Application.Initialize;     ncpf:='';     for c:=1 to length(cpf) do begin //#001       if not (cpf[c] in ['0'..'9','-','.',' '])         then result:='CPF inválido!';     end; //#001     if result=''       then begin //#002         for c:=1 to length(cpf) do begin //#003           if (cpf[c] in ['0'..'9'])             then ncpf:=ncpf+cpf[c];         end; //#003         case AnsiIndexStr(ncpf, ['00000000000','11111111111','22222222 222','33333333333','44444444444','55555555555','66666666666','77777777 777','88888888888','99999999999']) of //#004           0..9: result:='CPF inválido!';           else if length(ncpf)<>11             then result:='CPF inválido!'             else begin //#005               //Cálculo do 1º dígito               total:=0;               for c:=1 to 9 do                 total:=total+(StrToInt(ncpf[c])*c);               d1:=total mod 11;               //Cálculo do 2º dígito               total:=0;               for c:=1 to 8 do                 total:=total+(StrToInt(ncpf[c+1])*c);               total:=total+(d1*9);               d2:=total mod 11;               //Verificação final               if d1<>StrToInt(ncpf[10])                 then result:='CPF inválido!'                 else if d2<>StrToInt(ncpf[11])                   then result:='CPF inválido!'             end; //#005         end; //#004       end; //#002       if result=''         then result:='Ok!';   end; //#000 exports ValidaCPF, ValidaEmail; begin end." ---------------------------------------------------------------------- theo · 2010-05-02 08:43 Quote from: ezkiellg on May 02, 2010, 06:34:05 am/usr/bin/ld: cannot find -lfbookman This means it can't find the library. Where is it? In /usr/lib/ ? ---------------------------------------------------------------------- ezkiellg · 2010-05-02 17:05 I tested in ./ and all others Lazarus's search-paths ---------------------------------------------------------------------- Marc · 2010-05-02 18:46 this is a FAQ ---------------------------------------------------------------------- ezkiellg · 2010-05-23 22:36 I solved the problem with ShellScript. The FAQ section wasn't helpful this time. #!/bin/bash ln -s $(pwd)/libfbookman.so /lib ---------------------------------------------------------------------- Troodon · 2010-05-31 05:15 Quote from: ezkiellg on May 02, 2010, 07:05:29 pmI tested in ./ and all others Lazarus's search-paths This is Linux question, not a Lazarus/FPC question. On Linux, the local/current/work directory is not in the user or system PATH variable by default. All needed libraries, or symbolic links thereof, must be in one one of the system library directories (/lib; /usr/lib; /usr/local/lib). Once they are installed you need to make the system aware of them by either rebooting or issuing `ldconfig'.