Considerations for including the library as binary and source

I am trying to write an SSH client for iPhone, and I would like to use the open source libssh2 library for this. It is written in C.

How to enable this C library for my iPhone app? Should I compile it into some binary file that I include in my application, or add all the source code to my project and try to compile it along with the rest of my application?

+7
c iphone
source share
4 answers

I interpret this question like this:

"Should I compile the C library code once and include the binary library in my project? Or should I include all the source code and compile it every time I create my application?"

It depends. One of the projects I'm working on depends on several external libraries. Basically, we have a simple rule:

  • Do you think you need to frequently change code in the C library?

    • If you will frequently change code or update versions, include the source and create it along with the rest of your project.
    • If you are not going to change the code often or at all, it may make sense to simply include a ready-made binary file in the project.

Depending on the size of the library, you can set it up as a separate target in your project or for greater flexibility as a subproject of your main project.

If I were in your place, I would create libssh2 ahead of time and just include the binary library in my iPhone project. Of course, I would still keep the source of libssh2, if it needs to be restored in the future.

+3
source share

I have an iPhone app that is 90%. I had no problems adding third-party sources to my project and compiling. I am using Lua, zLib and libpng unchanged. I also included standard libraries such as unistd and libgen, and they just work and trade;

+2
source share

Three20 The iPhone library has a great opportunity to add your library to your xcode project. Make it a shot.

+1
source share

I think you will eventually find that you are better off creating it in a standalone library and linking it to your application. This simplifies integration into future applications. Another advantage is that it encourages code separation. If you feel pretty confident about the library, you can link your debug exe to the library release build and get extra performance.

I can’t think of any shortcomings in creating the library, after the initial cost of setting it up, and also about an additional project for change, if you have some changes that need to be made to all your projects. Even if you do not know how to create a library for the iPhone, this is a good reason to study.

Just adding a source to you, the project should also work fine.

0
source share

All Articles