Register FAQ / Rules Forum Spy Search Today's Posts Mark Forums Read
Go Back   MacRumors Forums > Apple Systems and Services > Programming > Mac Programming

Reply
 
Thread Tools Search this Thread Display Modes
Old May 28, 2012, 04:26 AM   #1
uisats
macrumors newbie
 
Join Date: May 2012
Xcode 4 plain C static library linking

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!
uisats is offline   0 Reply With Quote
Old May 28, 2012, 10:46 AM   #2
chown33
macrumors 603
 
Join Date: Aug 2009
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.
chown33 is offline   0 Reply With Quote
Old May 28, 2012, 12:12 PM   #3
uisats
Thread Starter
macrumors newbie
 
Join Date: May 2012
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.
uisats is offline   0 Reply With Quote
Old May 28, 2012, 12:26 PM   #4
chown33
macrumors 603
 
Join Date: Aug 2009
Just call me "duckie":
http://en.wikipedia.org/wiki/Rubber_duck_debugging
chown33 is offline   0 Reply With Quote
Old May 29, 2012, 02:56 AM   #5
uisats
Thread Starter
macrumors newbie
 
Join Date: May 2012
So true. Thanks!
uisats is offline   0 Reply With Quote

Reply
MacRumors Forums > Apple Systems and Services > Programming > Mac Programming

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Similar Threads
thread Thread Starter Forum Replies Last Post
Xcode library loading oddities printz Mac Programming 2 Apr 13, 2014 12:15 PM
Xcode - conio.h library ojb13004 Mac Programming 6 Dec 20, 2013 08:38 PM
Problems with linking to Boost dylibs in Xcode TastyCocoa Mac Programming 2 Aug 17, 2012 04:58 AM
Xcode 4 Dynamic Linking - Not working AT ALL rcplusplus Mac Programming 0 Aug 7, 2012 04:49 PM
Regex C++ Xcode library Poethetortoise Mac Programming 0 Aug 6, 2012 04:53 PM

Forum Jump

All times are GMT -5. The time now is 11:33 AM.

Mac Rumors | Mac | iPhone | iPhone Game Reviews | iPhone Apps

Mobile Version | Fixed | Fluid | Fluid HD
Copyright 2002-2013, MacRumors.com, LLC