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

Thread: MacOS X dylib suppport...

  1. #1

    MacOS X dylib suppport...

    A quick question for FreePascal users on MacOS X. Does the latest compiler, 1.9.6, link to *.dylib on MacOS X or is static linking the only possibility?
    <br /><br />There are a lot of people who are dead while they are still alive. I want to be alive until the day I die.<br />-= Paulo Coelho =-

  2. #2

    MacOS X dylib suppport...

    Hi, sorry I haven't answered this yet. I've barely used FPC on my Mac, so I can't say off the top of my head. But as far as I know it uses the standard linker (same as gcc), so I assume it does dynamic linking to .dylib and frameworks. I'll test it for sure this evening and let you know... that is something I need to know myself before planning on using FreePascal on a large project anyay...

  3. #3

    MacOS X dylib suppport...

    I look forward to your feedback.
    <br /><br />There are a lot of people who are dead while they are still alive. I want to be alive until the day I die.<br />-= Paulo Coelho =-

  4. #4

    MacOS X dylib suppport...

    Affirmative: I can dynamically link to .dylib libraries with FreePascal by either using the {$linklib} directive, or by passing the name of the library to the linker with the -k option (example: fpc -k"-framework Carbon" test.pas).

    Here is in example just for fun of creating a .dylib in C, and then linking to it in Pascal and calling a function. (I'm using Mac OS X 10.3, by the way)

    /* This file is called libtest.c */
    int test()
    {
    return 25;
    }
    /* EOF */

    ---

    {This file is called dylibtest.pas}
    program dylibtest;
    {$linklib test} {link to our .dylib}

    Function test : longint; cdecl; external;

    begin
    writeln (test);
    end.
    {EOF}

    ---

    And now compile the c file to a .dylib:
    cris$ gcc -dynamiclib -o libtest.dylib libtest.c -install_name /usr/local/lib/libtest.dylib
    Install the library to /usr/local/lib, then compile the pascal source:
    cris$ fpc dylibtest.pas
    Then run the brand new Mach-O, dynamically linked executable:
    cris$ ./dylibtest
    25
    And we get 25 printed on the screen just like we should!

    So that's a good sign at least, though simple. I don't know very much about linking and the complications that can arise... I'm downloading JEDI-SDL now, and hope I can get that working

  5. #5

    MacOS X dylib suppport...

    Hi Chris,
    This certainly sounds promising. I have a question...
    Instead of using {$linklib} directive shouldn't it also work with the external keyword? Or are you saying that the external keyword ie...

    [pascal]procedure SomeProcedure; cdecl; external 'libSDL-1.2.0.dylib';[/pascal]

    does not work on MacOS?

    You probably know this already, but I will mention it just in case, If you plan to play with JEDI-SDL, don't forget to install SDL first. The relevant packages are...
    http://www.libsdl.org/release/SDL-1.2.8.pkg.tar.gz for runtime
    or
    http://www.libsdl.org/release/SDL-de...2.8.pkg.tar.gz for the development package ( Project Builder + XCode )
    It looks like the the other SDL libararies ( SDL_image, SDL_Mixer etc ) need to be built.
    <br /><br />There are a lot of people who are dead while they are still alive. I want to be alive until the day I die.<br />-= Paulo Coelho =-

  6. #6

    MacOS X dylib suppport...

    > Or are you saying that the external keyword does not work does not work on MacOS?

    Unfortunately, that seems to be the case. If I remove the {$linklib} directive and use external 'libname', I get undefined symbol errors on link... like it can't find the library .

    I'm also having problem using exported variables from a linked library.

    I'm hoping it something I did wrong creating my libtest.dylib. I'll try linking to and using a REAL library, like SDL, when I have time. I do already have the SDL and SDL_Mixer frameworks installed on my Mac, thanks. I'm opening up my iBook and replacing the harddrive this weekend, but if I manage to do that without permanently damaging my computer, then I'll try to get the JEDI-SDL demos compiled in earnest.

    (by the way, if I can't get the current version of FreePascal to do what I want... do you know if the JEDI-SDL interfaces compile with GNU Pascal?)

    Thanks,
    - Chris

  7. #7

    MacOS X dylib suppport...

    Yes the interfaces do have Gnu Pascal compatability code in there, but it is untested with the latest Gnu Pascal compilers. It definately used to work.

    When you have a moment, can you confirm what the names of your libSDL*.dylibs are?
    <br /><br />There are a lot of people who are dead while they are still alive. I want to be alive until the day I die.<br />-= Paulo Coelho =-

  8. #8

    MacOS X dylib suppport...

    > When you have a moment, can you confirm what the names of your libSDL*.dylibs are?

    It is in a framework called SDL.framework (located at /Library/Frameworks/SDL.framework/ or ~/Library/Frameworks/SDL.framework/). The actual executable is named SDL (no extension) and is located at: /Library/Frameworks/SDL.framework/Versions/A/SDL

    does that help?

  9. #9
    Anonymous
    Guest

    MacOS X dylib suppport...

    FPC can link against dylibs, it's what the rtl does since Darwin (the OS core of MacOSX) has no kernel interface like linux which can be used without libc.

    Regarding MacOSX and SDL have a look at:
    http://www.freepascal.org/wiki/index...pecific_issues

    If you've question about it, ask on the fpc-mailing-lists, it will be probably read by someone who knows more about MacOSX than me

  10. #10

    MacOS X dylib suppport...

    FPC can link against dylibs, it's what the rtl does since Darwin (the OS core of MacOSX) has no kernel interface like linux which can be used without libc.

    Regarding MacOSX and SDL have a look at:
    http://www.freepascal.org/wiki/index...pecific_issues

    If you've question about it, ask on the fpc-mailing-lists, it will be probably read by someone who knows more about MacOSX than me
    <a>http://www.freepascal.org</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
  •