Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion Groups
General
GeneralPortable MacsHardwareNetworking
Applications
Mac ApplicationsEudoraFirefox / MozillaInternet ExplorerOutlook ExpressMS OfficeEntourageExcelPowerPointWordVirtual PCMedia PlayerOther MS Products
Programming
Mac ProgrammingCodeWarriorPerl
Country Specific
Australian Mac GroupUK Mac Group

Mac Forum / Programming / Mac Programming / July 2005



Tip: Looking for answers? Try searching our database.

Linking problem

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Ulrich Hobelmann - 30 Jul 2005 16:36 GMT
I have a simple static library, and a directory containing a test
program (on Mac OS X).

The make run is as follows:
make libfoo.a
cc -W -Wall -O2 -c -o messagebuffer.o messagebuffer.c
libtool -static -o libfoo.a messagebuffer.o
cd test; make test
cc -W -Wall -O2 -I.. -c -o main.o main.c
main.c: In function `main':
main.c:5: warning: unused variable `mb'
cc -W -Wall -o test ../libfoo.a main.o
ld: Undefined symbols:
_newMessageBuffer
make[1]: *** [test] Error 1
make: *** [test] Error 2

So libfoo.a DOES contain newMessageBuffer, because that function
is defined in messagebuffer.[ch], and disassembly shows that's
indeed there.

Even "cc -o bla libfoo.a test/main.o" gives the same ld error.
Any ideas?

Signature

XML is a prime example of retarded innovation.
    -- Erik Meijer and Peter Drayton, Microsoft Corporation

Ulrich Hobelmann - 30 Jul 2005 16:43 GMT
> I have a simple static library, and a directory containing a test
> program (on Mac OS X).
[quoted text clipped - 8 lines]
> main.c:5: warning: unused variable `mb'
> cc -W -Wall -o test ../libfoo.a main.o
 ^ That was probably wrong, but the following doesn't work either:

cc -W -Wall -L.. -o test -lfoo main.o
ld: Undefined symbols:
_newMessageBuffer
make[1]: *** [test] Error 1
make: *** [test] Error 2

Signature

XML is a prime example of retarded innovation.
    -- Erik Meijer and Peter Drayton, Microsoft Corporation

Paul Pluzhnikov - 30 Jul 2005 16:54 GMT
> Even "cc -o bla libfoo.a test/main.o" gives the same ld error. Any
> ideas?

Both of your link lines are incorrect. The correct link line is:

 cc -W -Wall -o test main.o ../libfoo.a

Explanation:
http://webpages.charter.net/ppluzhnikov/linker.html

Cheers,
Signature

In order to understand recursion you must first understand recursion.
Remove /-nsp/ for email.

 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.