New To Mac-Forums?

Welcome to our community! Join the discussion today by registering your FREE account. If you have any problems with the registration process, please contact us!

Get your questions answered by community gurus Advice and insight from world-class Apple enthusiasts Exclusive access to members-only contests, giveaways and deals

Join today!

 
Start a Discussion
 

Mac-Forums Brief

Subscribe to Mac-Forums Brief to receive special offers from Mac-Forums partners and sponsors

Join the conversation RSS
OS X - Development and Darwin Discussion and questions about development for Mac OS X.

XCode static library linking ld error


Post Reply New Thread Subscribe

 
Thread Tools
MSalman

 
Member Since: Oct 10, 2008
Posts: 2
MSalman is on a distinguished road

MSalman is offline
Hi,

I am trying to link a static library written by me and compiled with gcc (libtest.a) with XCode 3.1 project. After writing the library, I dragged the library file to the Frameworks folder as I've been doing previously.

But now whenever I call a function from the library( int myFuction( int ) ) and build the project I get the following ld error:

ld warning: in /Users/dev/lib/libtest.a, file is not of required architecture

Undefined symbols:
"_myFunction", referenced from:
_test_Function in mytest.o
ld: symbol(s) not found
collect2: ld returned 1 exit status


It seems that lib file is being located properly but for some reason ld can't find symbols in the file. Anyone have any idea how I go about fixing this problem? Help will be appreciated.


--
Thanks,
Salman
QUOTE Thanks
xstep

 
xstep's Avatar
 
Member Since: Jun 25, 2005
Location: On the road
Posts: 3,231
xstep is a name known to allxstep is a name known to allxstep is a name known to allxstep is a name known to allxstep is a name known to allxstep is a name known to allxstep is a name known to all
Mac Specs: 2011 MBP, i7, 16GB RAM, MBP 2.16Ghz Core Duo, 2GB ram, Dual 867Mhz MDD, 1.75GB ram, ATI 9800 Pro vid

xstep is offline
Quote:
Originally Posted by MSalman View Post
file is not of required architecture
If I was to guess, I'd say that part sounds like you have compiled it for the opposite architecture from what you are compiling the the calling code for.

CameraTime - Time lapse photography for novice and advanced users.

When asking questions, post the version of your software. You'll receive better answers.

Please post your results to the thread as it is good feedback.
QUOTE Thanks
MSalman

 
Member Since: Oct 10, 2008
Posts: 2
MSalman is on a distinguished road

MSalman is offline
Quote:
Originally Posted by xstep View Post
If I was to guess, I'd say that part sounds like you have compiled it for the opposite architecture from what you are compiling the the calling code for.
I figured that out

Well, actually I forgot to mention that I compiled this file with the arm-apple-darwin-gcc compiler (cross compiling) and the XCode project is for iPhone as well.

Isn't compiling the file using the arm-apple-darwin-gcc and XCode one and the same thing. Don't they have the same architecture?
QUOTE Thanks
deverloper.mj

 
Member Since: Nov 05, 2008
Posts: 1
deverloper.mj is on a distinguished road

deverloper.mj is offline
To fix the error, add the "-dynamiclib" flag.
Something like: gcc -dynamiclib *.c -o libmylibname.dylib
You can find more at:
<http://developer.apple.com/documentation/DeveloperTools/Conceptual/DynamicLibraries/Articles/CreatingDynamicLibraries.html#//apple_ref/doc/uid/TP40002073>

or for me it works like this.

g++ -dynamiclib -undefined dynamic_lookup -single_module -o libBlah.dylib *.o
QUOTE Thanks

Post Reply New Thread Subscribe


« NSLock | DASHCODE!!!!!!! help me with stack layout »
Thread Tools

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off
Forum Jump

Similar Threads
Thread
Thread Starter
Forum
Replies
Last Post
Error Code 36 ifanyonecan Other Hardware and Peripherals 6 08-22-2008 12:13 AM
Crash on boot - CIFSPlugin: LdapKerbDomainInit failed with error x0x0 OS X - Operating System 5 07-31-2007 08:00 PM
iTunes Tips And Tricks RJgamer iPod Hardware and Accessories 2 07-12-2007 11:59 AM
Just How Secure Are the 'Reset Safari' & 'Erase Free Space' Facility? scoot OS X - Operating System 3 05-30-2007 05:28 PM
XCode (Help with error messages) First - Using the word "new" as a variable nickypaul OS X - Development and Darwin 7 02-26-2005 11:38 AM

All times are GMT -4. The time now is 06:27 PM.

Powered by vBulletin
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
X

Welcome to Mac-Forums.com

Create your username to jump into the discussion!

New members like you have made this community the ultimate source for your Mac since 2003!


(4 digit year)

Already a member?