ryyst
ryyst

Reputation: 9801

Adding library to Xcode project

I'd like to add the libevent library to my Xcode project. I want to include it in the executable, because libevent isn't installed by default on Mac OS X.

I can compile the library from source using ./configure && make. I expected to find a .a library file, but there isn't. What do I do then? What files are relevant and how do I add them to Xcode?

Sorry for this very basic question, but I don't even know where to start.

Upvotes: 2

Views: 2925

Answers (2)

Stephen Chu
Stephen Chu

Reputation: 12832

Note that Xcode has this nasty "feature" that if it sees both dynamic and static versions of a library, it will always link against the dynamic one, even you specify the static one (.a) in your project. There's no way to override this "feafure" and you have to move or delete the dynamic one out of the library search paths.

Upvotes: 0

Michael Dautermann
Michael Dautermann

Reputation: 89559

First off, let's find out if your library truly got built. In the terminal, type in cd / and then find . -name libevent\* -print and see if the path for your libevent.a file actually appears.

If you can't find it, try running sudo make install from the top level of the library source code and then the library may end up getting installed in /usr/local/lib or some other appropriate place.

Once you do find the library, you can drag & drop it into your Project's list of Files in Xcode. Or you can include -levent in the link settings for your project.

Upvotes: 2

Related Questions