Recent

Author Topic: [SOLVED] fpc libraries do not work in freeBSD...  (Read 5818 times)

Fred vS

  • Hero Member
  • *****
  • Posts: 1675
    • miXimum is the DJ's best friend
[SOLVED] fpc libraries do not work in freeBSD...
« on: August 04, 2014, 10:54:02 pm »
Hello everybody.

I have posted this question in fpc-mailing list but... no answers.  :'(

So i try here  :-[

Fpc libraries compiled on freeBSD are unusable.
Python, Java, C and even fpc applications can not use them in freeBSD...

Look at that  (works on Linux):  =>

>> The fpc library: =>
Code: [Select]
library test ;
{$mode objfpc}

procedure fpctest(); cdecl;
begin
writeln('OK, it works...');
end;

exports
fpctest name 'fpctest';

begin
end.

>> The Python script: =>
Code: [Select]
#file fp_test.py
import string
import os,sys,platform
dia = sys.path[0]
from ctypes import*
fp_lib = "libtest.so"
fppathdll = os.path.join( dia , fp_lib)
fpdll = cdll.LoadLibrary(fppathdll)
fpdll.fpctest

Compile test.pas and run the python script: =>

>> python fp_test.py


=> Does not work and same error if fpc library is used by Python, Java (fpc lib compiled with Java-syntax), C or fpc applications:

Quote
> ~/libtest.so: Undefined symbol
> "operatingsystem_parameter_envp"

How can i help to fix that ?

Thanks.

Fred.
« Last Edit: August 08, 2014, 07:14:05 pm by Fred vS »
I use Lazarus 1.8.0 32/64 and FPC 3.0.3 32/64 on Linux Mint Mate 17 32/64, Windows 10, Windows 7 32/64, Windows XP 32,  FreeBSD 64 and Mac OS X Snow Leopard 32.
Widgetset: fpGUI, MSEgui, Win32, GTK2, Qt, Carbon.

https://github.com/fredvs

taazz

  • Hero Member
  • *****
  • Posts: 5363
Re: fpc libraries do not work in freeBSD...
« Reply #1 on: August 05, 2014, 12:01:49 am »
why are you always testing difficult things? What makes you think that python will set the console correctly and even more why do you thing that python will set your internal console variables correctly? How about start by returning an integer lets say 42 from a function and make sure that the function is declared as cDecl instead of pascal that is the default.
Good judgement is the result of experience … Experience is the result of bad judgement.

OS : Windows 7 64 bit
Laz: Lazarus 1.4.4 FPC 2.6.4 i386-win32-win32/win64

Fred vS

  • Hero Member
  • *****
  • Posts: 1675
    • miXimum is the DJ's best friend
Re: fpc libraries do not work in freeBSD...
« Reply #2 on: August 05, 2014, 12:15:20 am »
Quote
why are you always testing difficult things? What makes you think that python will set the console correctly and even more why do you thing that python will set your internal console variables correctly? How about start by returning an integer lets say 42 from a function and make sure that the function is declared as cDecl instead of pascal that is the default.

Hello taaz.

Hum, sorry but i do not understand you.
Is that fpc test-library so complicated ?

How can Python run simpler a imported function from a library ?
That code works perfectly on Linux 32/64 and Windows 32/64.
[edit] For windows, change in python code : fp_lib = "libtest.so" => fp_lib = "test.dll"

It does not work on freeBSD.

 
« Last Edit: August 05, 2014, 12:26:47 am by Fred vS »
I use Lazarus 1.8.0 32/64 and FPC 3.0.3 32/64 on Linux Mint Mate 17 32/64, Windows 10, Windows 7 32/64, Windows XP 32,  FreeBSD 64 and Mac OS X Snow Leopard 32.
Widgetset: fpGUI, MSEgui, Win32, GTK2, Qt, Carbon.

https://github.com/fredvs

taazz

  • Hero Member
  • *****
  • Posts: 5363
Re: fpc libraries do not work in freeBSD...
« Reply #3 on: August 05, 2014, 12:29:15 am »
Code: [Select]
////////////////
library test ;
{$mode objfpc}

function fpctest:integer;cdecl;
begin
  Result := 42;
end;

exports
fpctest name 'fpctest';

begin
end.
////////////////
Good judgement is the result of experience … Experience is the result of bad judgement.

OS : Windows 7 64 bit
Laz: Lazarus 1.4.4 FPC 2.6.4 i386-win32-win32/win64

Fred vS

  • Hero Member
  • *****
  • Posts: 1675
    • miXimum is the DJ's best friend
Re: fpc libraries do not work in freeBSD...
« Reply #4 on: August 05, 2014, 12:32:39 am »
Ok taazz, i will test your simpler library.  :-X

If it works, i offer you all what you want  ;)

But if it does not work, are you ok to help me to find the solution for fpc freeBSD libraries ?

I use Lazarus 1.8.0 32/64 and FPC 3.0.3 32/64 on Linux Mint Mate 17 32/64, Windows 10, Windows 7 32/64, Windows XP 32,  FreeBSD 64 and Mac OS X Snow Leopard 32.
Widgetset: fpGUI, MSEgui, Win32, GTK2, Qt, Carbon.

https://github.com/fredvs

taazz

  • Hero Member
  • *****
  • Posts: 5363
Re: fpc libraries do not work in freeBSD...
« Reply #5 on: August 05, 2014, 12:35:20 am »
Ok taazz, i will test your simpler library.  :-X

If it works, i offer you all what you want  ;)

But if it does not work, are you ok to help me to find the solution for fpc freeBSD libraries ?

Well I do not have my freebsd virtual machine set up yet after my hard drive crash a couple of months back but I'll try to help as much as I can with out hands on debugger.
Good judgement is the result of experience … Experience is the result of bad judgement.

OS : Windows 7 64 bit
Laz: Lazarus 1.4.4 FPC 2.6.4 i386-win32-win32/win64

Fred vS

  • Hero Member
  • *****
  • Posts: 1675
    • miXimum is the DJ's best friend
Re: fpc libraries do not work in freeBSD...
« Reply #6 on: August 05, 2014, 12:53:54 am »
Quote
Well I do not have my freebsd virtual machine set up yet after my hard drive crash a couple of months back but I'll try to help as much as I can with out hands on debugger.

Hum, im just back from freeBSD-box.

I have bad news for you and me  :-X (but good news for me  ;))

=> The Bad news => Your simpler fpc library does not work on freeBSD =>
Quote
> ~/libtest.so: Undefined symbol
> OSerror "operatingsystem_parameter_envp"

=> The Good news : =>, Yep, you will help me to find the solution  ;)
I use Lazarus 1.8.0 32/64 and FPC 3.0.3 32/64 on Linux Mint Mate 17 32/64, Windows 10, Windows 7 32/64, Windows XP 32,  FreeBSD 64 and Mac OS X Snow Leopard 32.
Widgetset: fpGUI, MSEgui, Win32, GTK2, Qt, Carbon.

https://github.com/fredvs

Laksen

  • Hero Member
  • *****
  • Posts: 624
    • J-Software
Re: fpc libraries do not work in freeBSD...
« Reply #7 on: August 05, 2014, 12:55:07 am »
Are you on a 64bit FreeBSD?

Fred vS

  • Hero Member
  • *****
  • Posts: 1675
    • miXimum is the DJ's best friend
Re: fpc libraries do not work in freeBSD...
« Reply #8 on: August 05, 2014, 01:06:29 am »
Quote
Are you on a 64bit FreeBSD?

Yes, freeBSD 10 64 bits.
I use Lazarus 1.8.0 32/64 and FPC 3.0.3 32/64 on Linux Mint Mate 17 32/64, Windows 10, Windows 7 32/64, Windows XP 32,  FreeBSD 64 and Mac OS X Snow Leopard 32.
Widgetset: fpGUI, MSEgui, Win32, GTK2, Qt, Carbon.

https://github.com/fredvs

Fred vS

  • Hero Member
  • *****
  • Posts: 1675
    • miXimum is the DJ's best friend
Re: fpc libraries do not work in freeBSD...
« Reply #9 on: August 08, 2014, 06:57:18 pm »
Applying Michal Wallace patch does the trick :=>
>> http://lists.freepascal.org/pipermail/fpc-devel/2014-August/034027.html

 ;)
I use Lazarus 1.8.0 32/64 and FPC 3.0.3 32/64 on Linux Mint Mate 17 32/64, Windows 10, Windows 7 32/64, Windows XP 32,  FreeBSD 64 and Mac OS X Snow Leopard 32.
Widgetset: fpGUI, MSEgui, Win32, GTK2, Qt, Carbon.

https://github.com/fredvs

BigChimp

  • Hero Member
  • *****
  • Posts: 5740
  • Add to the wiki - it's free ;)
    • FPCUp, PaperTiger scanning and other open source projects
Re: [SOLVED] fpc libraries do not work in freeBSD...
« Reply #10 on: August 10, 2014, 08:37:05 am »
So... have you added a bugtracker entry to give that information to the developers so the patch can be implemented?
Want quicker answers to your questions? Read http://wiki.lazarus.freepascal.org/Lazarus_Faq#What_is_the_correct_way_to_ask_questions_in_the_forum.3F

Open source including papertiger OCR/PDF scanning:
https://bitbucket.org/reiniero

Lazarus trunk+FPC trunk x86, Windows x64 unless otherwise specified

marcov

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 7630
Re: [SOLVED] fpc libraries do not work in freeBSD...
« Reply #11 on: August 10, 2014, 01:44:52 pm »
So... have you added a bugtracker entry to give that information to the developers so the patch can be implemented?

It's not really a solution, it is a workaround.

A patch should be tested against the following cases:

- fpc using fpc dll using normal linking
- C using fpc dll
- the above cases using dynload.

To not confuse the picture, don't use other languages.

In all cases, printing out paramstr and paramcount() and environment variables from inside the library should be verified to work.

Fred vS

  • Hero Member
  • *****
  • Posts: 1675
    • miXimum is the DJ's best friend
Re: [SOLVED] fpc libraries do not work in freeBSD...
« Reply #12 on: August 10, 2014, 08:33:20 pm »
Quote
So... have you added a bugtracker entry to give that information to the developers so the patch can be implemented?

Hum, no, because Michal Wallace old patch was not accepted (I dont want to impose something, even if it is better  :-X)

Quote
A patch should be tested against the following cases:

- fpc using fpc dll using normal linking
- C using fpc dll
- the above cases using dynload.

Indeed, not yet tested with normal linking (no use of dynlib), nor tested by a fpc application using fpc library.

What tested and works perfectly :

Java using fpc libraries ( with Java-dynload).
Python using fpc librares (witjh Pythn-dynload).

Thanks.

[EDIT]
Quote
In all cases, printing out paramstr and paramcount() and environment variables from inside the library should be verified to work.

Yep, it seems they are some problems with paramstr and paramcount(), i will do more test to see what is wrong...




« Last Edit: August 10, 2014, 08:38:10 pm by Fred vS »
I use Lazarus 1.8.0 32/64 and FPC 3.0.3 32/64 on Linux Mint Mate 17 32/64, Windows 10, Windows 7 32/64, Windows XP 32,  FreeBSD 64 and Mac OS X Snow Leopard 32.
Widgetset: fpGUI, MSEgui, Win32, GTK2, Qt, Carbon.

https://github.com/fredvs