Xcode 4 plain C static library linking

Discussion in 'Mac Programming' started by uisats, May 28, 2012.

  1. macrumors newbie

    Joined:
    May 28, 2012
    #1
    Hi!

    I would like to build a plain C console app in Xcode. I have 5 source files added to a project and a library, say libMyLib.a. The C source files obviously use the library. I can't get this to work, the linker produces errors of type "Undefined symbols for architecture x86_64..." I have checked with lipo that the static library supports this architecture. I tried various options suggested on forums: setting paths to headers (absolute, as well as using $(SOURCE_ROOT)), setting Build Phases -> Link Binary With Libraries, using workspaces. The same source code compiles fine when using command line gcc. I have also tried setting additional linker flags in Xcode to those that I use with make. Nothing works. What am I missing?

    Thanks in advance!
     
  2. macrumors 603

    Joined:
    Aug 9, 2009
    #2
    Post the complete text of the linker error message. Copy and paste it; don't paraphrase or retype it.

    Post the exact command-line you used in Terminal. Again: copy and paste.
     
  3. thread starter macrumors newbie

    Joined:
    May 28, 2012
    #3
    I was just about to post all the linker errors and command line results when I noticed that the Xcode project is missing one file... the one that utilizes the library wrapping its functions. The symbols were so similar to those supped by the library that I missed this! After adding it the code compiles without errors.

    Thank you for helping me find this silly problem.
     
  4. macrumors 603

    Joined:
    Aug 9, 2009
  5. thread starter macrumors newbie

    Joined:
    May 28, 2012

Share This Page