Page 1 of 3 123 LastLast
Results 1 to 10 of 23

Thread: Initialization sections not being run in Linux so.

  1. #1

    Initialization sections not being run in Linux so.

    I was just wondering if anyone had come across this. I've been testing a new engine I'm writing under Linux and have encoundered a few problems.

    The core os the system is a core shared object which sets up the shared memory manager. To accomplish sharing the memory manager (and creating the log files etc) I have a bunch of code in the initialization section of various units e.g

    [pascal]

    initialization

    GetMemoryManager(MemManager);

    end.

    [/pascal]

    Now I was getting a weird access violation so I put in a whole bunch of Writeln statements in the initialization sections to check they were being called. And guess what, they weren't :!:

    This appears to be different behavior from Free Pascal under windows at the engine works fine in windows under Delphi 5 and 2006 and Free Pascal 2.0.2.

    Anyone come across this before :?:

    I could work around this but my current design relys on these initialization sections being called.

    BTW Initialization sections are called in exe's under linux as the Logger class I am using is a modified one from the JEDI-SDL packed which we know works under Windows, Linux and OSX.
    <A HREF="http://www.myhpf.co.uk/banner.asp?friend=139328">
    <br /><IMG SRC="http://www.myhpf.co.uk/banners/60x468.gif" BORDER="0">
    <br /></A>

  2. #2

    Initialization sections not being run in Linux so.

    I have just confirmed this problem in a second DLL/SO. I this module I was generating a CRC32 data table in the initialization section, all crc checks were failing, once this call was moved to a point where it would be called it worked OK.

    :?
    <A HREF="http://www.myhpf.co.uk/banner.asp?friend=139328">
    <br /><IMG SRC="http://www.myhpf.co.uk/banners/60x468.gif" BORDER="0">
    <br /></A>

  3. #3

    Initialization sections not being run in Linux so.

    did you use sharemem?
    This is my game project - Top Down City:
    http://www.pascalgamedevelopment.com...y-Topic-Reboot

    My OpenAL audio wrapper with Intelligent Source Manager to use unlimited:
    http://www.pascalgamedevelopment.com...source+manager

  4. #4

    Initialization sections not being run in Linux so.

    I use my own shared memory manager dll. This has nothing to do with the shared memory system like i mentioned this works fine under free pascal and delphi under windows. It appears that the code in the initialization sections is just not called under linux when loading a .so.
    <A HREF="http://www.myhpf.co.uk/banner.asp?friend=139328">
    <br /><IMG SRC="http://www.myhpf.co.uk/banners/60x468.gif" BORDER="0">
    <br /></A>

  5. #5

    Initialization sections not being run in Linux so.

    This is from Free Pascal Unix FAQ
    Dynamic libraries

    These operating systems do support shared libraries (also called dynamic link libraries), Free Pascal currently does not emit position independant code (PIC), as required for the creation of shared libraries.

    Therefore, even though the linux compiler target permits creating shared libraries, the usage of that shared library may result in undefined behavior, especially if accessing global variables in the library. Creation of shared libraries is not recommended with the current version of the compiler.

    Importing code from shared libraries does work as expected though, since it does not require usage of position independant code.
    You have to wait for 2.2 version I suppose.

  6. #6

    Initialization sections not being run in Linux so.

    OK some more testing has confirmed that neither initialization/finalization or standard

    [pascal]

    begin
    // put code here
    end.
    [/pascal]

    works in a shared object under linux. initialization areas are run if you compile an application but not shared objects. I realise the shared library is not recommended in the current version, but there must be a way around this.

    In the old versions of pascal there were hooks like dllload and dllunload you could link into to detect when dll's were loaded, surely there must be something similar in unix based operating systems.

    Anyone got any ideas :?:
    <A HREF="http://www.myhpf.co.uk/banner.asp?friend=139328">
    <br /><IMG SRC="http://www.myhpf.co.uk/banners/60x468.gif" BORDER="0">
    <br /></A>

  7. #7
    Co-Founder / PGD Elder WILL's Avatar
    Join Date
    Apr 2003
    Location
    Canada
    Posts
    6,107
    Blog Entries
    25

    Initialization sections not being run in Linux so.

    Last time I checked through my flooded inbox (still have to send a note about Mantis ) there was quite a bit of hum about Linux and libraries and such under the FPC reporting.

    I'd go right to the barn on this one. Easiest way to get in touch with the FPC people is to hop on IRC on freenet or leave an interesting post on the FPC message boards. I usually get in contact with Florian or Vincent (fpcfan) through irc best. Almindor is a regular though and he's usually up to par with all things FPC and Laz...
    Jason McMillen
    Pascal Game Development
    Co-Founder





  8. #8

    Initialization sections not being run in Linux so.

    Not exactly sure on this particular issue but if it's just missing PIC support then you can get it working with using latest 2.1.1 and using the "-Cg" switch which will enable PIC code generation.

    Didn't test this so you might be first
    Feel the power of Open Source.
    <br />Feel the power of Free Pascal.

  9. #9

    Initialization sections not being run in Linux so.

    Quote Originally Posted by Almindor
    Not exactly sure on this particular issue but if it's just missing PIC support then you can get it working with using latest 2.1.1 and using the "-Cg" switch which will enable PIC code generation.

    Didn't test this so you might be first
    Thanks for the advice

    OK, I'll get the 2.1.1 source tree down and see if it works. I havne't compiled free pascal from scratch before, so it will be interesting. but at least we'll know if it solves the problem
    <A HREF="http://www.myhpf.co.uk/banner.asp?friend=139328">
    <br /><IMG SRC="http://www.myhpf.co.uk/banners/60x468.gif" BORDER="0">
    <br /></A>

  10. #10

    Initialization sections not being run in Linux so.

    Well I tried the 2.1.1 branch. I got the source from the daily snapshots.

    the -Cg switch generates an error when compiling. Without the switch is compiles OK, but behaves the same way as 2.0.4..

    back to the drawing board then...

    I'll post this on the Free Pascal community section.
    <A HREF="http://www.myhpf.co.uk/banner.asp?friend=139328">
    <br /><IMG SRC="http://www.myhpf.co.uk/banners/60x468.gif" BORDER="0">
    <br /></A>

Page 1 of 3 123 LastLast

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •