Page 1 of 2 12 LastLast
Results 1 to 10 of 15

Thread: Linking with Linux .so files

  1. #1

    Linking with Linux .so files

    Hello everybody.

    I'm new in this forum but I was coding games in C with Allegro for a long time, but since the TINS'06 competition where I wrote my entry in Pascal (Train) I decided to use only Pascal to create games.

    So I decided to write a wrapper to use Allegro in Pascal, and I success in Windows but now I'm trying to port it to Linux and it doesn't work. It says it can't find the library files (-lalleg). All the files it needs are in /usr/local/lib and theirs names are liballeg_unsharable.a, liballeg.so.4.2 (this is a link to the real shared object) and alpas42.so (I wrote this one to allow Delphi-lovers to use it :toocool: ).

    I'm using next code to link the files:

    [pascal]
    (**** from albase.pas ****)
    INTERFACE

    CONST
    { Access to the dynamic modules. }
    {$IFDEF WIN32}
    ALLEGRO_SHARED_LIBRARY_NAME = 'alleg42.dll';
    ALL_PAS_SHARED_LIBRARY_NAME = 'alpas42.dll';
    {$ENDIF}
    {$IFDEF UNIX}
    ALLEGRO_SHARED_LIBRARY_NAME = 'liballeg.so.4.2';
    ALL_PAS_SHARED_LIBRARY_NAME = 'alpas42.so';
    {$LINKLIB alleg_unsharable}
    {$ENDIF}
    [/pascal]

    And the next to declare a procedure:

    [pascal]
    (**** from aldraw.pas ****)
    INTERFACE

    USES
    albase, albitmap; { Needs some basic definitions. }

    (* Clipping. *)
    PROCEDURE al_set_clip_rect (bmp: AL_BITMAPptr; x1, y1, x2, y2: AL_INT); CDECL;
    EXTERNAL ALLEGRO_SHARED_LIBRARY_NAME NAME 'set_clip_rect';
    [/pascal]

    And to build the examples (using GNU/makefile):

    Code:
    (**** from makefile.all ****)
    # Executables.
    $(EXMDIR)/%$(BINSUF): $(EXMDIR)/%.dpr
    	fpc -Fu$&#40;LIBDIR&#41; FE$&#40;EXMDIR&#41; -FU$&#40;LIBDIR&#41; -WG+ $< -o$@
    As I've said, it compiles, links and runs perfectly in Windows XP but it doesn't in Linux.

    I'm using Free Pascal version 2.0.2 and GCC 4.0.3 in an actualized Kubuntu (no Lazarus) in a IBM ThinkCentre (P4, 512Mb blah blah...).

    The Windows XP is in the same computer (other partition) with same compilers and also using MinGW32 5.1 and Msys 1.0.

    Can anybody help me?

    [comment] I know, there are a lot of great libraries for Free Pascal to make great games, but I like Allegro and I'll still using it. Please, do not try to convince me.
    No signature provided yet.

  2. #2

    Linking with Linux .so files

    What exactly doesn't work? Does it compile in linux? Does it link? if not, what errors do you get?
    Feel the power of Open Source.
    <br />Feel the power of Free Pascal.

  3. #3

    Linking with Linux .so files

    I think you need to link to the .so directly. I had to do this when interfacing with mysql I had to add

    -Fl/usr/local/lib/mysql

    as a compiler option.

    perhaps you need to do the same here :?:
    <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>

  4. #4

    Linking with Linux .so files

    I guess you've to install the allegro development package.
    <a>http://www.freepascal.org</a>

  5. #5

    Linking with Linux .so files

    [quote="Almindor"]What exactly doesn't work? Does it compile in linux? Does it ]
    It compiles but doesn't link. It says "ld: Can't find -lalleg".
    [quote="technomage"]I think you need to ]
    :doh: I'll try it. Thanks for the suggestion, but today was a bussy day and I need to rest.
    Quote Originally Posted by FPK
    I guess you've to install the allegro development package.
    I did it, but thanks for remember me this. Some years ago I forgot to install the development package of a library and it was too embarrasing ops:
    No signature provided yet.

  6. #6

    Linking with Linux .so files

    Make sure that the shared object is accessible from your login, so it may be a rights/security issue.
    <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 =-

  7. #7

    Linking with Linux .so files

    I've tried the -Fl option but it doesn't work. I think I should learn more about the way Linux uses the .so files. I'll finish with the documentation and then release it; may be somebody who has more experience can fix it. Until then, I can use it in Win32.
    No signature provided yet.

  8. #8

    Linking with Linux .so files

    Why don´t you use the Allegro bindings for pascal

    http://allegro-pas.sourceforge.net/

  9. #9

    Linking with Linux .so files

    Great! Somebody suggest Allegro.pas to somebody! This is the happyest day of my life!
    But there's a problem...

    A wrapper to use the Allegro library with Pascal compilers
    by ?ëu?±o Mart??nez, December,2006.
    I'm "that" ?ëu?±o Mart??nez. Anyway, thanks for the try.
    No signature provided yet.

  10. #10

    Linking with Linux .so files

    Make sure it's the right name you use. Also -lname must match for ld. Basicly check out what the filename of allegro so file is, if the symlink to name.so.#.#.# is there and is right, and if it accepts -lallegro

    You can test alot with gcc to see what that uses. (btw you have to explicitly tell this to gcc, so if it works with -lallegro in gcc and not via fp {don't forget, both use ld as linker} it's odd)
    Feel the power of Open Source.
    <br />Feel the power of Free Pascal.

Page 1 of 2 12 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
  •