Forum > macOS / Mac OS X
[solved] *.dylib and "initialization" section under Mac
Jonas Maebe:
--- Quote from: marcov on January 10, 2011, 12:58:53 pm ---Try to call FPC_INITIALIZE and FPC_FINALIZE from C before and after usage.
--- End quote ---
These are the wrong names (they are internal aliases for the standard Delphi routines initialize() and finalize()), but in general please do not try to manually initialise the RTL using hacks like that.
In the best case, things will work partially and only the initialisation code of the library source file itself won't be run. In the worst case, things will start crashing. It will only make debugging the actual problem harder.
Frantic:
I built FPC from SVN: Free Pascal Compiler version 2.5.1 [2010/11/16] for i386
but also tried on Free Pascal Compiler version 2.4.2rc1 [2010/11/16] for i386
--- Code: ---$ ./tw8730c
Segmentation fault
--- End code ---
I had seen this error before (when developing my own dylib) and added following code to library files:
--- Code: ---library ...
...
begin
Writeln('');
end.
--- End code ---
After this I get following error:
--- Code: ---$ ./tw8730c
result of function Lib2Func
tw8730c did not complete successfully
--- End code ---
marcov, I tried to call it, but seams like there is no such function exported...
Jonas Maebe:
--- Quote from: Frantic on January 10, 2011, 09:19:57 pm ---I built FPC from SVN: Free Pascal Compiler version 2.5.1 [2010/11/16] for i386
but also tried on Free Pascal Compiler version 2.4.2rc1 [2010/11/16] for i386
--- Code: ---$ ./tw8730c
Segmentation fault
--- End code ---
I had seen this error before (when developing my own dylib) and added following code to library files:
--- Code: ---library ...
...
begin
Writeln('');
end.
--- End code ---
After this I get following error:
--- Code: ---$ ./tw8730c
result of function Lib2Func
tw8730c did not complete successfully
--- End code ---
--- End quote ---
The correct fix is to compile all dylibs with -k-no_order_inits. See the note under "Mac OS X 10.6" compatibility at http://www.freepascal.org/down/i386/macosx-ftp.freepascal.org.var, or in /Developer/Documentation/Free Pascal Compiler/Getting Started.rtf
Frantic:
I added "-k-no_order_inits" to compiler params... and my problem was solved!
1 000 000 thanks to you, man! You saved me :)
Navigation
[0] Message Index
[*] Previous page