Xcode "Link Binary with Libraries" and Introducer "External libraries to link"

I was having trouble getting my Xcode project to build. After some researching, I realised that I hadn't added the library I was referencing to my project.

If I add the library like this via Xcode, then the project builds successfully:

  • Click on your project in the upper left of the left pane (the blue icon).
  • In the middle pane, click on the Build Phases tab. 
  • Under "Link Binary With Libraries", click on the plus button.
  • Click "Add Other..." (this is a 3rd party library)
  • Choose the filename (libVinylTrack.a) from my project's Source folder.

The issue is, of course, that I need to add this configuration via Introducer rather than the Xcode GUI -  else my settings could be overwritten later.

The place to do this seems to be in Config > XCode (MacOSX) > Debug > External libraries to link. However, I'm not sure what I'm supposed to enter here.

To clarify, the library I want to link is <project folder>/Source/libVinylTrack.a

Extra Linker Flags

-L$(SRCROOT)/../../Source
-lVinylTrack

Note that the lib prefix is removed.

http://www.rapidtables.com/code/linux/gcc/gcc-l.htm

Does it works for you?

1 Like

That works perfectly - thank you!

 

This does not seem to work for me, I see the library in the other linker flags in xcode but I get this error when building

library not found for -llibgmp


If I do the normal way of going to the Build Phases tab and "Link Binary With Libraries".  I can build successfully. But the problem is introJucer keeps overwriting the project. Which is annoying, Is there a way to tell introJucer to stop doing this?
 

Is the path properly set?

-L$(SRCROOT)/../../Source
-lgmp

In that case the libgmp.a must be located at “yourJuceProjectFolder/Source/libgmp.a”.

You have to change the path if it is not there.

Yeah I changed the -L flag to the correct path, I even tried just the -l flag and put the full path of the library. The paths show up in Xcode. So I think it might be an Xcode bug.

I had the same behavior with the ICU library and XCode 5.1.1

Oddly the Avid libraries link fine the regular way, so this may have something to do with the way the libaries are built (static).

Rail

Yeah mine is  .a file , I can add fine if go to the build phases then Link with binary libaries  Is there way to tell introJucer to do that instead, Cause it keeps overwriting. What was your solution?

I don’t use introjucer because I use a local modified version of JUCE and it overwrites the local copy if I save the project losing my changes.

Rail

AFAIK there’s currently no way to tell The Introjucer to do that.

You could set the library with Xcode, and then observe the commands generated by Xcode during the build process. That’s what i do sometimes in order to find the compile options needed when there’s no more fun at the “trial and error” party.

Thanks so much I looked at the build logs and found the answer:

I had to put -lgmp instead of -llibgmp , I guess you cant include the lib part?

No, that’s why i precised in a previous post that “Note that the lib prefix is removed.” :wink:

so sorry I missed that