Forum > Other
FreeBSD shared library problems
bbrtj:
Some time ago I created this issue in fpc's bugtracker: https://gitlab.com/freepascal.org/fpc/source/-/issues/39427
The patch I supplied works (although it needs to be applied manually now), but now I spotted a new problem with it. Including an unit like cwstring causes the library to be unloadable in other programs. Attempting to load such library crashes the program with Bus Error.
These shared library issues are not only problematic when developing pascal. For example, if you use doublecmd on FreeBSD, it's close to impossible to get working plugins (like zip.wcx).
I'd like to ask for help getting these issues resolved (as the issue had no activity at all). I'm pretty sure it can be resolved by modifying .as files in rtl/freebsd directory of the fpc source. I moved linux dllprt0.as to freebsd, added the operatingsystem_parameters patch to it and it somehow seems to work with cwstring now, but still not enough to compile working doublecmd plugins (now Access Violation).
Edit: The problem is with compiling shared libraries to be used in other programs, not with loading shared libraries in a program. Sorry if it was not clear enough.
Fred vS:
Sadly it seems that BSD (FreeBSD, OpenBSD, NetBSD) is no longer cherished by FPC devs.
AmatCoder:
Do you link the executable with "-export-dynamic" option?
As far as I can remember(*) FreeBSD executables need to be linked using the "-export-dynamic" flag to load dynamic libraries/plugins with dlopen().
(*) At least in C language.
bbrtj:
--- Quote from: AmatCoder on May 01, 2025, 03:34:54 pm ---Do you link the executable with "-export-dynamic" option?
--- End quote ---
Actually I link no executables, I'm loading the library in Perl through FFI. My doublecmd is installed from pkg and is able to load plugins (which are libraries). The problem lies entirely in creation of shared libraries by FPC, I excluded all other options.
Fred vS:
--- Quote from: bbrtj on May 01, 2025, 03:46:36 pm ---
--- Quote from: AmatCoder on May 01, 2025, 03:34:54 pm ---Do you link the executable with "-export-dynamic" option?
--- End quote ---
Actually I link no executables, I'm loading the library in Perl through FFI. My doublecmd is installed from pkg and is able to load plugins (which are libraries). The problem lies entirely in creation of shared libraries by FPC, I excluded all other options.
--- End quote ---
Hello.
What is the result for this?:
--- Code: Pascal [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---$ readelf -d <your_fpc_lib>
Did you add the -fPIC -Sh parameters at compilation?
Also, better use cmem with FreeBSD, place it as first unit in the uses clause.
And finally, add this at end of code:
--- Code: Pascal [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---initialization Set8087CW($133f); // Mask all FPU exceptions
Navigation
[0] Message Index
[#] Next page