Sign in Join

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

Mailing lists / fpc-pascal / 2000-10

Free Pascal Problem

6 messages · 3 people · –

Reply by email Subscribe to this list Your subscription

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

Christian Wulff

Hello!

I have a problem with FreePascal.
When I start to run, or start to compile a program there is always the message:

Can't open fp___.err

What is the problem????
Please help me!!

I'm not subscribed in a mailinglist, so please answer to:

Thanks so very much!!
Chris

Alexis Halbot-Schoonaert
to Christian Wulff

Hello,

I wanted to trye to build my own dll.
I wanted it to be usable under win32 and linux.

So, i used the sample provided with fpc for win.
Compiled under windows, no problem. I had to adapt it to linux and tried to compile. No problem.
But, when i run the program (under linux), i have this message :

./dlltest: error in loading shared libraries:
libtestdll.so: cannot open shared object file:
No such directory

Though, libtestdll.so is in the same directory than dlltest. I tried to copy libtestdll.so in /usr/sbin, and i have the same problem. So, supposed it was not because of the path...

Could you tell me what is wrong ?

And i'd like the main program and the library to use the c call convention (with cdecl ?). What is the way to do it ?

This is the modified source :

program dlltest;
procedure p1(x:pointer); external 'testdll' name 'P1';
procedure proc2(x:longint); external 'testdll' name 'Proc2';
var   s : string;
begin
  s:='';
  writeln('Main: Hello!');
  p1(nil);
  //writeln('Main: ',Hinstance,' ',Hprevinst);
  writeln('Main: testdll s string = ',s);
  s:='Changed by program';
  proc2(1234);
  writeln('Main: press enter');
  readln;
end.
library testdll;
var  teststr : string;
procedure P1(var s:string);export;
var  p:array[0..255] of char;
begin
  length(s);
end;
procedure P2(x:longint);export;
begin
  writeln('DLL: Argument X=',x);
  writeln('DLL: New teststr="',teststr,'"');
end;
procedure P3(var t);export;
var
  p : pointer;
begin
  p:=Addr(T);
  p:=p;
end;
procedure P4(x1:pointer);export;
begin
  Inc(x1);
end;
procedure NewExit;
begin
  writeln('DLL: Exit from testdll');
end;

exports
P1 name 'P1',
P2 name 'Proc2',
P3,
P4 resident; //,
//teststr name 'FPC_string';

begin
  //writeln('DLL: HInstance ',Hinstance,'  PrevInst ',Hprevinst,'
DLLReason ',DLLreason,'  DLLParam ',DLLparam);
  teststr:='DLL init done';
  ;
end.

Thank you for your help.

Reguards,

Alexis.

Sebastian Günther
to Alexis Halbot-Schoonaert
Alexis Halbot-Schoonaert wrote 8 lines
./dlltest: error in loading shared libraries: libtestdll.so: cannot open shared object file: No such directory Though, libtestdll.so is in the same directory than dlltest. I tried to copy libtestdll.so in /usr/sbin, and i have the same problem. So, supposed it was not because of the path...

Not if you didn't run 'ldconfig' after copying the .so to /usr/sbin... [BTW, you should use /usr/local/bin or /usr/local/sbin instead...]

And i'd like the main program and the library to use the c call convention (with cdecl ?). What is the way to do it ?

Attention, this is not the default on Win32. Win32 libraries normally use 'stddecl' conventions. On Linux, cdecl is standard, of course.

program dlltest; procedure p1(x:pointer); external 'testdll' name 'P1';

[...]

procedure p1(x:pointer); cdecl; external 'testdll' name 'P1';

and so on

- Sebastian

Alexis Halbot-Schoonaert
to Sebastian Günther

Hello,

Show quoted text 13 lines
Alexis Halbot-Schoonaert wrote: > > ./dlltest: error in loading shared libraries: > libtestdll.so: cannot open shared object file: > No such directory > > Though, libtestdll.so is in the same directory than dlltest. I tried to > copy libtestdll.so in /usr/sbin, and i have the same problem. So, > supposed it was not because of the path... Not if you didn't run 'ldconfig' after copying the .so to /usr/sbin... [BTW, you should use /usr/local/bin or /usr/local/sbin instead...]

I copied my library in /usr/local/bin
I also used ldconfig

I tried to use the library before and after copiing, using ldconfig MyDirectory
but it didn't work.
I have always the same error when i want to use it :

./dlltest: error in loading shared libraries:
libtestdll.so: cannot open shared object file:
No such directory

Show quoted text 17 lines
> And i'd like the main program and the library to use the c call > convention (with cdecl ?). What is the way to do it ? Attention, this is not the default on Win32. Win32 libraries normally use 'stddecl' conventions. On Linux, cdecl is standard, of course. > program dlltest; > > procedure p1(x:pointer); external 'testdll' name 'P1'; [...] procedure p1(x:pointer); cdecl; external 'testdll' name 'P1'; and so on - Sebastian

thank you for your help.
Alexis.

Sebastian Günther
to Alexis Halbot-Schoonaert
Alexis Halbot-Schoonaert wrote 6 lines
> Not if you didn't run 'ldconfig' after copying the .so to /usr/sbin... > [BTW, you should use /usr/local/bin or /usr/local/sbin instead...] I copied my library in /usr/local/bin I also used ldconfig

Ehmm, just one moment. This is a library, not a program. So it must be /usr/local/lib of course, sorry!
Try copy your .so file there, then check wether the file /etc/ld.so.conf contains the path "/usr/local/lib" (on some distributions this is not the case by default, don't know why). Then run ldconfig, and everything should work fine.

- Sebastian

Alexis Halbot-Schoonaert
to Sebastian Günther
Show quoted text 6 lines
Ehmm, just one moment. This is a library, not a program. So it must be /usr/local/lib of course, sorry! Try copy your .so file there, then check wether the file /etc/ld.so.conf contains the path "/usr/local/lib" (on some distributions this is not the case by default, don't know why). Then run ldconfig, and everything should work fine.

Yes, everything is OK now !
Thank you very much :o)

Alexis.