Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

titaniumdecoy

macrumors member
Original poster
Oct 13, 2005
86
0
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.
 

PhoneyDeveloper

macrumors 68040
Sep 2, 2008
3,114
93
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.
 

titaniumdecoy

macrumors member
Original poster
Oct 13, 2005
86
0
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?
 

PhoneyDeveloper

macrumors 68040
Sep 2, 2008
3,114
93
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.
 

titaniumdecoy

macrumors member
Original poster
Oct 13, 2005
86
0
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.
 

PhoneyDeveloper

macrumors 68040
Sep 2, 2008
3,114
93
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.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.