1

I've found answers to this question, but they don't work for me. I'm trying to build a C++ project in Xcode that uses external libraries from ffmpeg and openCV, and I can't figure out how to link them. As recommended, I go the "Build Phases" screen, and there's a place for "Link Binary with Libraries." One of the libraries I need to link with is at /usr/local/lib/libavutil.a. When I try to add a library, a list box pops up showing two folders: "OS X 10.11" and "Developer Frameworks". The library I need is not in either of these folders. I tried clicking on "Add Other" and a file chooser dialog comes up, but if I type "/usr/local/lib/libavutil.a" in the search box, the dialog doesn't accept it.

I've found that typing '-lswcale -lavcodec -lavdecice' etc. on the "Other linker flags" line in "Build Settings" works, but it's not what I hoped for. I was hoping to get a file chooser dialog, where I could simply click on the libraries I want to use.

Is there a way to accomplish what I want?

saulspatz
  • 5,011
  • 5
  • 36
  • 47

3 Answers3

3

If I understand correctly what you are asking, you simply want to "set" the file chooser dialog at the right place, right?

If so, you just have to press Cmd + Alt + G once you are in the file chooser dialog, after clicking on "Add Other..." in the "Link Binary with Libraries" menu. A "Go to the folder:" dialog comes up, and there you can type the fullpath to the file or the folder you are looking for.

Hope that helped!

ecombette
  • 46
  • 5
2

Since nobody else has provided a working answer, I am documenting that the only only thing I have found that works it to set the search paths for the libraries under "Library Search Paths" and then to add a -l flag for each library in the "Other Linker Flags" section, just as you would on the command line command line:enter image description here

saulspatz
  • 5,011
  • 5
  • 36
  • 47
1

According to this, you can try:

1) Open the left panel, goto "ProjectName", Targets, Build phases, Link binary with libraries and select your library.

2) Open the left panel, goto "ProjectName", Project, Header Search Paths, write the path where the headers of your library are (the .h files, usually in /usr/local/include).

3) Open the left panel, goto "ProjectName", Project, Library Search Paths, write the path where your libraries are (the .a or .dylib files, usually in /usr/local/lib)

I hope you can confirm that this work for Xcode7.

On Step 1) You can also:

  • Under "Link Binary With Libraries", click on the plus button.

  • Click "Add Other..." (this is a 3rd party library).

  • Choose the filename (/usr/local/lib/libavutil.a).

P.S., I can't flag as a Dup, because that was not an acepted answer

Community
  • 1
  • 1
Rama
  • 3,222
  • 2
  • 11
  • 26
  • I've already done this, but it's insufficient. This tells the linker where to look for libraries, but not which libraries to link. On the command line, you would type, "-L/usr/local/lib", but you'd still have to type, "-lavutil, -lswscale" and so on, for each the libraries you want to link. (There may be hundreds of libraries in /usr/local/lib. You wouldn't want the linker to search all of them when trying to resolve some symbol.) – saulspatz Mar 28 '17 at 14:42
  • @saulspatz Edited, Added aditional steps to chose the filename – Rama Mar 28 '17 at 15:50
  • Thanks. This doesn't work for me either. This is what I meant when I said that if I typed the name of the library in the search box, the dialog won't accept it. I never get to a point where I see a list of the contents of /usr/local/lib and just click the ones I want. – saulspatz Mar 28 '17 at 15:57
  • I edited the question to try to clarify what I was saying about the file chooser dialog. – saulspatz Mar 28 '17 at 16:08