Professional Web Applications Themes

how to include dynamic library? - Mac Programming

Hello does anyone make use of "libtiff" ?? For reading tiff files? I am unsure how to include the library libtiff**.dylib into my codewarrior project. Can someone tell me how? Thanks a lot ! -- Best Regards Eleen...

  1. #1

    Default how to include dynamic library?


    Hello

    does anyone make use of "libtiff" ??
    For reading tiff files?

    I am unsure how to include the library
    libtiff**.dylib into my codewarrior project.

    Can someone tell me how?

    Thanks a lot !
    --
    Best Regards
    Eleen


    neele Guest

  2. #2

    Default Re: how to include dynamic library?

    In article <bt2pvf$uab$singnet.com.sg>, neele
    <com> wrote:
     

    Add it to your project however you normally add files to your project.

    If it's not installed on OS X by default, you should include the
    library inside your application's bundle.

    Wade
    Wade Guest

  3. #3

    Default Re: how to include dynamic library?

    Hello thanks for reply.
    I am unable to add the dylib like "Add File" to project.
    I cannot select it.

    How to library inside your application's bundle.??

    I did try copying the files to my project folder. but does not works

    Thanks

    --
    Best Regards
    Eleen
    "Wade Williams" <spam.dogwatchsw.com> wrote in message
    news:020120040115582506%spam.dogwatchsw.com... 
    >
    > Add it to your project however you normally add files to your project.
    >
    > If it's not installed on OS X by default, you should include the
    > library inside your application's bundle.
    >
    > Wade[/ref]


    neele Guest

  4. #4

    Default Re: how to include dynamic library?

    In article <bt34kn$v7t$singnet.com.sg>,
    "neele" <com> wrote:
     

    Is your project Mach-O? Did you check the file mappings for .dylib?
    Sean Guest

  5. #5

    Default Re: how to include dynamic library?

    Actually my codewarrior project have 2 targets one for OS X and another for
    OS 9
    So one is Mach-O ya? another is not.

    Currently running on OS X.

    How should i add the file mapping? I added one TEXT, extension .dylib What
    should i set?
    It still does not allow me to add the file.

    I am having libtiff.a file sa well. It also cannot be added.
    Can you kindly advise on how i should add for the file mappings for .dylib
    and .a ??

    Thanks a lot !!

    --
    Best Regards
    Eleen
    "Sean McBride" <org> wrote in message
    news:aei.ca... 
    >
    > Is your project Mach-O? Did you check the file mappings for .dylib?[/ref]


    neele Guest

  6. #6

    Default Re: how to include dynamic library?

    In article <btagiu$o85$singnet.com.sg>,
    "neele" <com> wrote:
     

    Well your OS 9 target is definately NOT Mach-O. But your OS X target
    might also not be Mach-O. If you are using CFM (instead of Mach-O),
    then you cannot link to .dylib libraries. Are you sure you are using
    Mach-O?
     

    Off the top of my head, I don't know what the exact settings should be.
    Did you check CW Mach-O sample projects and/or the CW manual?
    Sean Guest

  7. #7

    Default Re: how to include dynamic library?

    Hello

    Thanks. Finally i knows how to add the file mapping to
    get the libtiff.a file to be added into the project.

    Actually i need static shared library instead of dynamic library.

    If i am not wrong, both my target are not using Mach-O. Should be
    CFM...How should i differentiate ? is it thru whether i am using carbon
    framework??

    Btw the adding of file type at file mapping of CW, i need to clicked the
    choose button
    at file mapping to select the file and codewarrior will load the file type.
    It is so simple
    but guess for a newbie..is not so straight forward ;o at times.

    But now issues is after adding in i am able to select the file libtiff.a
    but having error.

    Error : Cannot load main source file
    (/usr/local/lib/libtiff.a)

    I using the settings at file mapping to be file type >> MLIB
    compiler >>
    Metrowerks c/c++
    edit language >>
    c/c++

    Do you happen to know why??
    Guess my setting might not be correct even thou currently able to add
    the libtiff.a into my project.

    Thanks a lot !

    --
    Best Regards
    Eleen
    "Sean McBride" <org> wrote in message
    news:aei.ca... [/ref]
    for 
    >
    > Well your OS 9 target is definately NOT Mach-O. But your OS X target
    > might also not be Mach-O. If you are using CFM (instead of Mach-O),
    > then you cannot link to .dylib libraries. Are you sure you are using
    > Mach-O?
    > [/ref]
    What [/ref]
    ..dylib 
    >
    > Off the top of my head, I don't know what the exact settings should be.
    > Did you check CW Mach-O sample projects and/or the CW manual?[/ref]


    neele Guest

  8. #8

    Default Re: how to include dynamic library?

    In article <btb1fp$son$singnet.com.sg>,
    "neele" <com> wrote:
     

    Go to the target settings, what is the linker? "Mac OS X PowerPC
    Mach-O" is Mach-O and "Macintosh PowerPC" is CFM. I agree the names are
    not that good.
     

    Probably your target is CFM. libtiff.a is Mach-O. You cannot put
    Mach-O libraries in CFM projects, and vice versa too.

    The best thing may be to convert your project to Mach-O. See this file:

    /Applications/Metrowerks CodeWarrior/Release Notes/Mach-O
    Notes/Making_Mach-O_Projects_Note.txt
    Sean Guest

  9. #9

    Default Re: how to include dynamic library?

    I double checked and the project is using CFM as the
    linker is "Macintosh PowerPC"

    I don't think i can convert to MACH-O the project
    due to some compatibility issues..

    Is there anyway to compile the libtiff for use under CFM?

    Thanks alot.

    --
    Best Regards
    Eleen
    "Sean McBride" <org> wrote in message
    news:aei.ca... 
    >
    > Go to the target settings, what is the linker? "Mac OS X PowerPC
    > Mach-O" is Mach-O and "Macintosh PowerPC" is CFM. I agree the names are
    > not that good.

    >
    > Probably your target is CFM. libtiff.a is Mach-O. You cannot put
    > Mach-O libraries in CFM projects, and vice versa too.
    >
    > The best thing may be to convert your project to Mach-O. See this file:
    >
    > /Applications/Metrowerks CodeWarrior/Release Notes/Mach-O
    > Notes/Making_Mach-O_Projects_Note.txt[/ref]


    neele Guest

  10. #10

    Default Re: how to include dynamic library?

    In article <btd5oo$34r$singnet.com.sg>,
    "neele" <com> wrote:
     

    Which issues?
     

    Create a CFM library project, add the source, and compile it. :)

    But I suspect it would be easier for you to move your app to Mach-O, not
    moving libtiff to CFM.
    Sean Guest

  11. #11

    Default Re: how to include dynamic library?

    Since this thread is regarding linking to .dylib files, I think I have
    something to say. I had a .dylib file, plus a .a and a .la file in
    /usr/local/lib.

    To bundle it in my project, (I used Xcode, for this Cocoa project, but
    that doesn't really matter, I think), I was told to temporarily remove
    the .dylib file from /usr/local/lib, and compile the project after a
    clean. This actually put the "code" inside the application itself, and
    it ran perfectly on all computers so far, without this particular
    library installed. (It was tested on a G3, G4, and a G5).

    While I'm at it, is this a bad method of including 'stuff' inside the
    application's bundle -- even though it seems to work? mb.
    M Guest

  12. #12

    Default Re: how to include dynamic library?

    M <com> wrote: 
     

    That's exactly how I've done it in the past.
     

    It does seem a little "hackish", and I'd be interested in hearing of a
    "better" way.

    The problem, as I see it, is that libraries often come as a dynamic
    (.dylib) file and a static (.a) file in the same directory. Even
    specifically adding the .a file to the project only seems to add the
    normal -llibrary_name flag to the linker command line. The linker is
    already passed the -dynamic flag by default, because of the heavy use of
    dynamic libraries in the Xcode tools. The linker goes searching for the
    dynamic library first, and if it finds a match, includes a link to that.

    Another way to get around it would be to put your static libraries in a
    seperate directory (say /usr/local/lib/static or something), add that
    path to your library search path (-L/usr/local/lib/static), add the
    library as usual (-llibrary_name), and finally, add this flag:

    -search_paths_first
    By default when the -dynamic flag is in effect, the -lx and
    -weak-lx options first search for a file of the form
    `libx.dylib' in each directory in the library search path, then
    a file of the form `libx.a' is searched for in the library
    search paths. This option changes it so that in each path
    `libx.dylib' is searched for then `libx.a' before the next path
    in the library search path is searched.

    (sorry about the width, that's a paste from man ld)

    The linker should go searching for your library in the path you
    specify first, find the static library and include that.

    --
    *--------------------------------------------------------*
    | ^Nothing is foolproof to a sufficiently talented fool^ |
    | Heath Raftery, HRSoftWorks _\|/_ |
    *______________________________________m_('.')_m__ _______*
    Heath Guest

  13. #13

    Default Re: how to include dynamic library?

    > > To bundle it in my project, (I used Xcode, for this Cocoa project, but 
    >
    > That's exactly how I've done it in the past.[/ref]

    So I'm not alone. ;-)

    Have you ever had eny problems in running the executable?

    And what exactly is in the .dylib, .la and .a files? (I know the .a
    file is text, but don't know what it's for exactly). I've tried
    searching on the 'Net, but the topic is somewhat difficult to pinpoint.
    (Know of any on-line sources)?

    And also, (unrelated), since the G5 is 64-bit but can run 32-bit
    instructions, when Xcode compiles the application with the "Target CPU"
    variable set to "PowerPC G5", does it produce a 64-bit based
    application, or is it 32-bit? (I know it won't run on a G4 or G3
    because it's sort of obvious, and I've tested it). m.
    M Guest

  14. #14

    Default Re: how to include dynamic library?

    In article <1g7bave.17i5c2sm9wmvwN%com>,
    com (M) wrote:
     

    A .dylib is a dynamic library, a.k.a. a shared library. When you link
    against a .dylib, it basically goes through your app and figures out
    which functions are in the .dylib, and it makes a note of where the
    library is on your disk. When you actually run the app, the dynamic
    linker loads the library and hooks everything together at runtime. So,
    if the library isn't there, your app will fail to launch. The advantages
    of this is that you use less disk space, because every app refers to the
    same copy on disk, and you use less memory, because clever memory
    management means that only one copy of the library needs to be in memory
    no matter how many apps are using it.

    A .a is a static library. When you link against a .a file, the entire
    file gets loaded into your binary. At this point, it's no longer a
    separate file, its contents are stuffed into your binary along with all
    of your files. At this point, the compiled file no longer depends on the
    library. You can take it to another computer, delete the original .a,
    whatever, and the app will continue to work. Since every app that links
    against a .a file keeps a copy of it, both on disk and in memory, this
    can use more of both.

    The fact that .dylibs can use so much less memory and disk space is why
    practically every library on OS X is provided as a .dylib. But if you
    need to get around potential incompatibility, then linking against a .a
    to include a file in your app is more or less the same as including a
    ..dylib in your app's bundle.
    Michael Guest

  15. #15

    Default Re: how to include dynamic library?

    In article <1g79e9m.ba3q3wypb1u4N%com>,
    <com> wrote:
     

    What happened is you linked with the static library instead of the
    dynamic. The code was indeed included in the application itself. You
    didn't need to remove the .dylib - you simply needed to add the .a file
    to your project.

    What you describe is not including stuff in the application's bundle.
    It's including it inside the application itself.

    I'm sure some will disagree with me, but given a choice between a
    static library or a dynamic library, I always choose the static
    library. Wherever possible, I want everything needed to run my
    application inside my application.

    Wade
    Wade Guest

  16. #16

    Default Re: how to include dynamic library?

    In article <090120041425213016%spam.dogwatchsw.com>,
    Wade Williams <spam.dogwatchsw.com> wrote:
     

    I agree for libraries that are not an official part of the system
    distribution. If it is a library that exists on the system, then I think
    you should link against the dynamic library. That reduces your app's
    disk and memory footprint at no extra risk. If it's a nonstandard
    library, why not, it's easier than bundling a .dylib with your app and
    it doesn't have any downsides that I can see.
    Michael Guest

  17. #17

    Default Re: how to include dynamic library?

    In article <1g7bave.17i5c2sm9wmvwN%com>,
    com (M) wrote:
     

    It produces a 32-bit application, but the application may use
    instructions specific to the G5. Apple does not yet provide a way to
    build a fully 64-bit application.

    Hope this helps,
    Eric

    --
    Eric Albert stanford.edu
    http://rescomp.stanford.edu/~ejalbert/
    Eric Guest

  18. #18

    Default Re: how to include dynamic library?

    In article <090120041425213016%spam.dogwatchsw.com>,
    Wade Williams <spam.dogwatchsw.com> wrote:
     
    >
    > What happened is you linked with the static library instead of the
    > dynamic. The code was indeed included in the application itself. You
    > didn't need to remove the .dylib - you simply needed to add the .a file
    > to your project.[/ref]

    In Xcode at least, I don't think this will do it. AFAIK, adding the .a
    to your project (using the "Add file to Project" or "Add Framework to
    Project") only adds -llibrary_name to the linker instructions. So if the
    equivalent dylib can be found, it will be used. Read my first post in
    this thread for a way I've got around it.
     

    I agree with you to some extent - when it is a library which will not be
    available on the destination platform. If the dylib is going to be
    available, I'll just use the dylib because it results in a smaller
    executable, and those with newer versions of the library (in a System
    Update for example) will automatically be able to take advantage of them.

    --
    Heath
    __________________________________________________ ______
    | *Nothing is foolproof to a sufficiently talented fool* |
    | _\|/_ |
    |________________________________________m(. .)m_________|
    Heath Guest

  19. #19

    Default Re: how to include dynamic library?

    In article <1g7bave.17i5c2sm9wmvwN%com>,
    com (M) wrote:
     
    > >
    > > That's exactly how I've done it in the past.[/ref]
    >
    > So I'm not alone. ;-)
    >
    > Have you ever had eny problems in running the executable?[/ref]

    One big problem was that there is no easy way to do the same with
    libSystem. You can't get it as a static library and you can't get the
    linker to use a static library of your own for functions defined in it.
    You can't move it (just about *everything* relies on dynamically binding
    to it - move it and you upset a lot of critical things - I tried ;) ).
    Instead, I had to use Xcode's SDK support for older systems. That set a
    environment variable of NEXT_ROOT, meaning the linker used an older
    libSystem.

    Other than that, no I don't think I've had execution problems.

    --
    Heath
    __________________________________________________ ______
    | *Nothing is foolproof to a sufficiently talented fool* |
    | _\|/_ |
    |________________________________________m(. .)m_________|
    Heath Guest

  20. #20

    Default Re: how to include dynamic library?

    > What happened is you linked with the static library instead of the 

    That didn't work in Xcode. ;-)
     

    Understood. I noticed the App/Contents/MacOS/App executable file
    increased in size upon including the library in the application. But it
    only seemed to increase in size according to the functions that my
    program called from the library, as expected. mb.
    M Guest

Page 1 of 2 12 LastLast

Similar Threads

  1. include xml data file in Flex Library Project
    By marcbc in forum Macromedia Flex General Discussion
    Replies: 3
    Last Post: March 18th, 03:22 PM
  2. Updating include/library item
    By Marshy75 in forum Macromedia Contribute General Discussion
    Replies: 7
    Last Post: July 19th, 05:48 PM
  3. How to include Dynamic Data within a <script> tag
    By rachplayer in forum Dreamweaver AppDev
    Replies: 0
    Last Post: April 11th, 04:10 PM
  4. Replies: 6
    Last Post: January 13th, 07:36 PM

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
  •  

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139