Re: [fpc-pascal] Calling fpc libraries from other languages on freebsd/amd64 (bis)
Aaaargh, difficult t find help here... In the original thread [fpc-devel] (hack) calling fpc libraries from other languages on freebsd/amd64 of Michal Wallace michal.wallace at gmail.com Michael Wallace said that he has find the solution := Anyway, the problem appears to be in this file: http://svn.freepascal.org/cgi-bin/viewvc.cgi/trunk/rtl/freebsd/x86_64/dllpr= (But this file is no more accessible. ;-( ) It has the comment: # FreeBSD RunTime dynamic loader only # calls the functions specified by -init # as functions without parameters # Thus, it is not possible to retrieve argc, argv and envp # On x86_64 CPU, using weak for the operatingsystem_parameter_XXX # allows to bind to main program parameters, # but this does not seem to work for i386 loader. Then at the bottom: /* Do not fail linkage if argc, argv and envp are not found. */ .weak operatingsystem_parameter_argc .weak operatingsystem_parameter_argv .weak operatingsystem_parameter_envp My change was to comment these lines out and copy the lines from prt0.as : .global operatingsystem_parameter_envp .global operatingsystem_parameter_argc .global operatingsystem_parameter_argv .set operatingsystem_parameter_envp,operatingsystem_parameters+0 .set operatingsystem_parameter_envp,operatingsystem_parameters+0 .set operatingsystem_parameter_envp,operatingsystem_parameters+0 Then after recompiling fpc, I was able to compile a *.so file usable from python. But... It seems like the original .weak version was done quite deliberately, so I suspect that if I submit a patch, it would break things for other people. OTOH, I'd like to get a fix for my issue into trunk. So, it seems that Michal Wallace do not sent a patch for that. It seems too that his solution was for Python, maybe it works for Java too. But later Sergei Gorelkin answers : Studying sources of FreeBSD dynamic loader reveals that, although it does not pass argc, argv and envp to the initialization function in .init section, it *does* pass them to procedures pointed to from .init_array section. Generally, .init_array is considered as a replacement for .init. Therefore, the correct solution would be to change initialization to use .init_array and remove all associated hacks. Regards, Sergei So i do not know where is the good solution, please, wonderful fpc people, help us and me... Fred - Many thanks ;-) -- View this message in context: http://free-pascal-general.1045716.n5.nabble.com/Calling-fpc-libraries-from-other-languages-on-freebsd-amd64-bis-tp5719667p5719869.html Sent from the Free Pascal - General mailing list archive at Nabble.com. ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] Calling fpc libraries from other languages on freebsd/amd64 (bis)
On 03/08/2014 01:36, fredvs wrote: What can i do ? Start providing source code so people can follow what you are trying to do instead of having to guess would be a nice step ;) ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] Calling fpc libraries from other languages on freebsd/amd64 (bis)
In our previous episode, fredvs said: /usr/home/fred/fpGUIlib/demos/demo_Java/libfpgui.so: /usr/home/fred/fpGUIlib/demos/demo_Java/libfpgui.so: Undefined symbol operatingsystem_parameter_envp ;-( So, fpc 2.7.1 does not do the trick... What can i do ? First test it with a normal FPC program. That symbol is weak, maybe the java loader can't handle that. ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] Calling fpc libraries from other languages on freebsd/amd64 (bis)
Start providing source code so people can follow what you are trying to do instead of having to guess would be a nice step ;) First, fpGUI must be installed = https://github.com/graemeg/fpgui/tree/develop Then. go there = https://github.com/fredvs/fpGUIlib - Click on Download Zip. (middle/end of page) and unzip it. - In /fpGUIlib/src/ change in extrafpc.cfg the directory of fpGUI according yours. (maybe read ReadMe.txt, it is explained). - And finally compile the library In /fpGuilib/src/ = $ fpc @extrafpc.cfg fpgui.pas Thats all for compilation. ___ Now test the library: Copy the new compiled library /src/libfpgui.so into ~/fpGUIlib/demos/demo_Java Then run the java demo with: -In terminal do: - cd ~/fpGUIlib/demos/demo_Java (go in java demo path) - java -Djava.library.path=. fpg_demo When i try to run it on freeBSD, i get error messages... Many thanks to help. Fred - PS: If you try the same things with Linux, it should work. (for me it works). - Many thanks ;-) -- View this message in context: http://free-pascal-general.1045716.n5.nabble.com/Calling-fpc-libraries-from-other-languages-on-freebsd-amd64-bis-tp5719667p5719864.html Sent from the Free Pascal - General mailing list archive at Nabble.com. ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] Calling fpc libraries from other languages on freebsd/amd64 (bis)
Ooops, in last topic, branch freebsd-fixes must be selected... Here re-explaination from sctatch = Start providing source code so people can follow what you are trying to do instead of having to guess would be a nice step ;) First, fpGUI must be installed = https://github.com/graemeg/fpgui/tree/develop Then. go there = https://github.com/fredvs/fpGUIlib Select branch: = freebsd-fixes - Click on Download Zip. (middle/end of page) and unzip it. - In /fpGUIlib/src/ change in extrafpc.cfg the directory of fpGUI according yours. (maybe read ReadMe.txt, it is explained). - And finally compile the library In /fpGuilib/src/ = $ fpc @extrafpc.cfg fpgui.pas Thats all for compilation. ___ Now test the library: Copy the new compiled library /src/libfpgui.so into ~/fpGUIlib/demos/demo_Java Then run the java demo with: -In terminal do: - cd ~/fpGUIlib/demos/demo_Java (go in java demo path) - java -Djava.library.path=. fpg_demo When i try to run it on freeBSD, i get error messages... Many thanks to help. Fred - PS: If you try the same things with Linux, it should work. (for me it works). - Many thanks ;-) -- View this message in context: http://free-pascal-general.1045716.n5.nabble.com/Calling-fpc-libraries-from-other-languages-on-freebsd-amd64-bis-tp5719667p5719865.html Sent from the Free Pascal - General mailing list archive at Nabble.com. ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] Calling fpc libraries from other languages on freebsd/amd64 (bis)
Yes, it is still me... You may try the compiled and binary java demo for Linux 64 bit := https://sites.google.com/site/fiensprototyping/demo_Java.tar.gz Download and unzip the demo. Then := -In terminal do: - cd /demo_Java (go in java demo path) Then run it with: - java -Djava.library.path=. fpg_demo It is a demo for Linux 64 bit. The same demo, with fpGUIlib.so compiled on freeBSD does not work... - Many thanks ;-) -- View this message in context: http://free-pascal-general.1045716.n5.nabble.com/Calling-fpc-libraries-from-other-languages-on-freebsd-amd64-bis-tp5719667p5719866.html Sent from the Free Pascal - General mailing list archive at Nabble.com. ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] Calling fpc libraries from other languages on freebsd/amd64 (bis)
Is it solved in trunk fpc version ? Why don't you try? I have install a brand new trunk version of fpc 2.7.1 64 bit on freeBSD 10 64 bit. The library was successfully compiled. But, sadly, i get hat error message while trying to run a java application who use the library (that java application works in linux) := [fred@pcbsd-fred] ~/fpGUIlib/demos/demo_Java% java -Djava.library.path=./ fpg_demo Exception in thread main java.lang.UnsatisfiedLinkError: /usr/home/fred/fpGUIlib/demos/demo_Java/libfpgui.so: /usr/home/fred/fpGUIlib/demos/demo_Java/libfpgui.so: Undefined symbol operatingsystem_parameter_envp at java.lang.ClassLoader$NativeLibrary.load(Native Method) at java.lang.ClassLoader.loadLibrary0(ClassLoader.java:1929) at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1847) at java.lang.Runtime.loadLibrary0(Runtime.java:870) at java.lang.System.loadLibrary(System.java:1119) at fpg_demo.main(fpg_demo.java:148) ;-( So, fpc 2.7.1 does not do the trick... What can i do ? Thanks - Many thanks ;-) -- View this message in context: http://free-pascal-general.1045716.n5.nabble.com/Calling-fpc-libraries-from-other-languages-on-freebsd-amd64-bis-tp5719667p5719861.html Sent from the Free Pascal - General mailing list archive at Nabble.com. ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] Calling fpc libraries from other languages on freebsd/amd64 (bis)
On 29/06/2014 21:52, fredvs wrote: There was exactly the same problem in a earlier topic : = http://lists.freepascal.org/pipermail/fpc-devel/2013-November/032950.html Is it solved in trunk fpc version ? Why don't you try? ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] Calling fpc libraries from other languages on freebsd/amd64 (bis)
Hello everybody... Hum... no answers or no ideas ? Thanks. Fred - Many thanks ;-) -- View this message in context: http://free-pascal-general.1045716.n5.nabble.com/Calling-fpc-libraries-from-other-languages-on-freebsd-amd64-bis-tp5719667p5719700.html Sent from the Free Pascal - General mailing list archive at Nabble.com. ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] Calling fpc libraries from other languages on freebsd/amd64 (bis)
Ooops, i forget to note something... My goal was to expose some pascal library to Java, of course those fpc libraries follow the Java-native-library-way. Those libraries loaded by a Java application work with Linux (tested on Mint 32/64) but fail to work with freeBSD... Thanks. Fred. - Many thanks ;-) -- View this message in context: http://free-pascal-general.1045716.n5.nabble.com/Calling-fpc-libraries-from-other-languages-on-freebsd-amd64-bis-tp5719667p5719668.html Sent from the Free Pascal - General mailing list archive at Nabble.com. ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal