Library

Discussion in 'iOS Programming' started by titaniumdecoy, Sep 8, 2008.

  1. titaniumdecoy macrumors member

    Joined:
    Oct 13, 2005
    #1
    I want to use libdict, a C library I downloaded from the internet, in an iPhone application. Is this possible? I know how to include frameworks in a project but I am not sure how to include a library. The download comes with a bunch of files ending in .c, .h, and ".c,v" and ".h,v". The example code it comes with uses -ldict in the Makefile, but it won't compile.

    Do I need to install these files on my mac? If so, how would I do that? Or is it possible to only include the files in the project in question?

    Thanks.
     
  2. PhoneyDeveloper macrumors 68030

    PhoneyDeveloper

    Joined:
    Sep 2, 2008
    #2
    It might be possible to include this library in a phone app. You won't be able to use it as a framework or as the library that its makefile wants to build. The author claims that it's an ANSI C library. To make this work you'll need to add all of the .c source files and .h header files to your project. I don't know if there's a way to build a static library for an iPhone project so you'll just have to add it to your project and see if it builds.

    When I've done this there were always some problems and some effort to make things like this build. There may be missing includes. And bits of source code that don't compile.

    I recommend you start with a new project and add all the source and header files and go from there.
     
  3. titaniumdecoy thread starter macrumors member

    Joined:
    Oct 13, 2005
    #3
    Hi PhoneyDeveloper, thanks for the advice. I can't figure out what the files ending in ".c,v" and ".h,v" are for. Are they necessary?
     
  4. PhoneyDeveloper macrumors 68030

    PhoneyDeveloper

    Joined:
    Sep 2, 2008
    #4
    Forget about the comma, v files. They come from cvs, a source code control system. Everyone today uses subversion, the successor to cvs. I have no idea why someone would include those files in a source code download. Throw em away, ignore em, there's nothing you can do with them.
     
  5. titaniumdecoy thread starter macrumors member

    Joined:
    Oct 13, 2005
    #5
    Thanks again. I added the files to my project and the C files (.c and .h) appear fine but the C++ wrapper class (.cpp and .hpp) do not compile. I tried changing the extension from .cpp to .mm (for Objective-C++) but apparently ANSI C++ is significantly different as it will not compile because of numerous syntax errors. Is it possible to designate a file as ANSI C++ rather than Objective-C++? Thanks.
     
  6. PhoneyDeveloper macrumors 68030

    PhoneyDeveloper

    Joined:
    Sep 2, 2008
    #6
    If a file has the cpp extension it will be compiled as C++. I don't think there's any reason to change the extension to mm. Those files won't have any objective-C in them.

    If they don't compile correctly as c++ then they might be missing some includes or may have some incompatibilities with gcc or the gcc standard library. You'll need to understand what the errors are in order to figure out what the problem is and fix it.
     

Share This Page