[SOLVED] fpc libraries do not work in freeBSD... lazarus / 62-General ---------------------------------------------------------------------- Fred vS · 2014-08-04 20:54 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. ---------------------------------------------------------------------- taazz · 2014-08-04 22:01 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. ---------------------------------------------------------------------- Fred vS · 2014-08-04 22:15 Quotewhy 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. ---------------------------------------------------------------------- taazz · 2014-08-04 22:29 Code: [Select]//////////////// library test ; {$mode objfpc} function fpctest:integer;cdecl; begin   Result := 42; end; exports fpctest name 'fpctest'; begin end. //////////////// ---------------------------------------------------------------------- Fred vS · 2014-08-04 22:32 Ok taazz, i will test your simpler library.  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 ? ---------------------------------------------------------------------- taazz · 2014-08-04 22:35 Quote from: Fred vS on August 05, 2014, 12:32:39 amOk taazz, i will test your simpler library.  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. ---------------------------------------------------------------------- Fred vS · 2014-08-04 22:53 QuoteWell 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  (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 ---------------------------------------------------------------------- Laksen · 2014-08-04 22:55 Are you on a 64bit FreeBSD? ---------------------------------------------------------------------- Fred vS · 2014-08-04 23:06 QuoteAre you on a 64bit FreeBSD? Yes, freeBSD 10 64 bits. ---------------------------------------------------------------------- Fred vS · 2014-08-08 16:57 Applying Michal Wallace patch does the trick :=> >> http://lists.freepascal.org/pipermail/fpc- devel/2014-August/034027.html ---------------------------------------------------------------------- BigChimp · 2014-08-10 06:37 So... have you added a bugtracker entry to give that information to the developers so the patch can be implemented? ---------------------------------------------------------------------- marcov · 2014-08-10 11:44 Quote from: BigChimp on August 10, 2014, 08:37:05 amSo... 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 · 2014-08-10 18:33 QuoteSo... 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  ) QuoteA 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] QuoteIn 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...