Can't link library statically

Discussion in 'Mac Programming' started by davbeck, Oct 17, 2008.

  1. davbeck macrumors regular

    Joined:
    May 16, 2008
    Location:
    Reno, NV
    #1
    I am trying to link mysql to my project for limited client access. I installed mysql vie macports and added the libmysqlclient.a file to xcode, and it compiles and runs fine on my machine. I then take the program to any other computer (mac obviously) and it just quits immediately. Running from the command line it points out that it can not link to libmysqlclient.dylib.

    How can I compile my program so that the library is included in the executable? (or less desirable, linked to a copy of the library in my bundle).

    Note: I am compiling with release settings.
     
  2. kainjow Moderator emeritus

    kainjow

    Joined:
    Jun 15, 2000
    #2
    Make sure the library itself isn't linking against something that doesn't exist on other computers besides yours.
     
  3. Sayer macrumors 6502a

    Sayer

    Joined:
    Jan 4, 2002
    Location:
    Austin, TX
    #3
    That happens with pre-built binaries from macports. You have to build from source. Or find a framework for mysql that shouldn't have that probleem
     
  4. davbeck thread starter macrumors regular

    Joined:
    May 16, 2008
    Location:
    Reno, NV
    #4
    OK heres what I did to get it working.
    First I found a post about how if you drag the .a file into xcode, it adds the folder for that file into the search path. If there are also dylibs in that folder, it will use them instead of the a. so I placed all of my static libraries into a different folder.
    After I did that, it gave me errors about how it was missing functions (from mysql dependancies). So I also linked to all of those libraries in my project. Once I did that it compiled correctly and will now run on other computers.

    The problem with macports is annoying though. Any advise on compiling from source with universal? I have had some pretty bad experience trying this (hence the use of macports).
     

Share This Page