Re: Linker fails to link in static library
Re: Linker fails to link in static library
- Subject: Re: Linker fails to link in static library
- From: Philip White <email@hidden>
- Date: Mon, 17 Jan 2011 17:18:14 -0600
On Jan 17, 2011, at 5:00 PM, Xochitl Lunde wrote:
>
> I add the resulting library to another
> > project, make sure it is listed in the "Link Binary with Libraries"
> > phase for the appropriate target, and try to build, but the linker
> > gives me an error for every reference to a function from the library.
> >
> What happens if you add the library path to "Library Search Paths" and add "-lyourlib" to "Other Linker Flags" field? Will it link then? You could also add the full path to "Other Linker Flags" field: "$path/path/yourlib.a" (This should be approx. the same thing as adding it to the "Link Binary with Libraries" field, but just for the sake of determining if something else will work you can try it.)
>
> Could your dependencies be out of order?
>
> Could you be building this new library only for 1 architecture, but not the first architecture that tries to link? Should be able to run $> file yourlib.a and see what architectures it built for and whether or not Xcode REALLY built a static library, or if it built a dynamic library with a .a file extension. In your library info it should say "Mach-O Type" = Static Library (I think).
Hi, thanks for the tips. Architectures all appear to be i386 and nothing is being built for multiple archs. 'file' prints out:
librivregistrar-no.a: current ar archive random library
Which seems to indicate that it is a static library (I guess) but doesn't say anything about architecture. I didn't find anything on the man page for file about determining architecture and I'm not sure how to do that with otool either, but The following is the build line from the (successful) build of the library:
Libtool /Users/philip/Work/Builds/Debug/librivregistrar-no.a normal i386
cd /Users/philip/Work/rivregistrar-no
setenv MACOSX_DEPLOYMENT_TARGET 10.5
/Developer/usr/bin/libtool -static -arch_only i386 -syslibroot /Developer/SDKs/MacOSX10.6.sdk -L/Users/philip/Work/Builds/Debug -L/Users/philip/Work/rivregistrar-no/../rivregistrar "-L/Users/philip/Work/rivregistrar-no/../Arcade Typing Tutor" -filelist /Users/philip/Work/Builds/rivregistrar-no.build/Debug/rivregistrar-no.build/Objects-normal/i386/rivregistrar-no.LinkFileList -lEWS -lValidateUniversal -o /Users/philip/Work/Builds/Debug/librivregistrar-no.a
----> And the following is the build line from the (unsuccessful) linking of the built library into my other project:
Ld "/Users/philip/Work/Builds/Debug/Arcade Typing Tutor-FLTK.app/Contents/MacOS/Arcade Typing Tutor-FLTK" normal i386
cd "/Users/philip/Work/Arcade Typing Tutor"
setenv MACOSX_DEPLOYMENT_TARGET 10.5
/Developer/usr/bin/g++-4.0 -arch i386 -isysroot /Developer/SDKs/MacOSX10.5.sdk -L/Users/philip/Work/Builds/Debug -L/opt/local/lib "-L/Users/philip/Work/Arcade Typing Tutor" "-L/Users/philip/Work/Arcade Typing Tutor/../Builds/Debug" -F/Users/philip/Work/Builds/Debug -filelist "/Users/philip/Work/Builds/Arcade Typing Tutor.build/Debug/Arcade Typing Tutor-FLTK.build/Objects-normal/i386/Arcade Typing Tutor-FLTK.LinkFileList" -mmacosx-version-min=10.5 -framework Carbon -lfltk -framework OpenGL -framework AGL -lfltk_gl -lfltk_images -lfltk_jpeg -lEWS -lValidateUniversal /Users/philip/Work/Builds/Debug/librivregistrar-no.a -o "/Users/philip/Work/Builds/Debug/Arcade Typing Tutor-FLTK.app/Contents/MacOS/Arcade Typing Tutor-FLTK"
ld: warning: Fl_Input::~Fl_Input()has different visibility (default) in /Developer/SDKs/MacOSX10.5.sdk/usr/local/lib/libfltk.a(Fl_Input.o) and (hidden) in /Users/philip/Work/Builds/Arcade Typing Tutor.build/Debug/Arcade Typing Tutor-FLTK.build/Objects-normal/i386/GameWindow.o
Undefined symbols:
"regActivate(char const*, REGbool*)", referenced from:
setupRegistration() in main.o
buy(int) in regWindow.o
"regInit(char const*, REGpublisherInfo*)", referenced from:
setupRegistration() in main.o
"regGetRegistered()", referenced from:
buy(int) in regWindow.o
"regGetError(char**)", referenced from:
setupRegistration() in main.o
setupRegistration() in main.o
setupRegistration() in main.o
setupRegistration() in main.o
setupRegistration() in main.o
setupRegistration() in main.o
setupRegistration() in main.o
setupRegistration() in main.o
buy(int) in regWindow.o
buy(int) in regWindow.o
"_fopen$UNIX2003", referenced from:
Fl_JPEG_Image::Fl_JPEG_Image(char const*)in libfltk_images.a(Fl_JPEG_Image.o)
Fl_Help_View::load(char const*)in libfltk.a(Fl_Help_View.o)
Fl_BMP_Image::Fl_BMP_Image(char const*)in libfltk_images.a(Fl_BMP_Image.o)
Fl_Shared_Image::reload() in libfltk.a(Fl_Shared_Image.o)
Fl_XPM_Image::Fl_XPM_Image(char const*)in libfltk.a(Fl_XPM_Image.o)
Fl_XBM_Image::Fl_XBM_Image(char const*)in libfltk.a(Fl_XBM_Image.o)
"regPurchaseWithKey(char const*, char**, REGbool*, REGbool*)", referenced from:
buy(int) in regWindow.o
"regAddActivationInfo(REGactivationInfo*)", referenced from:
setupRegistration() in main.o
setupRegistration() in main.o
setupRegistration() in main.o
setupRegistration() in main.o
"regAddSKU(char const*, char const*)", referenced from:
setupRegistration() in main.o
setupRegistration() in main.o
ld: symbol(s) not found
collect2: ld returned 1 exit status
----> And here is a partial output of "nm -mg /Users/philip/Work/Builds/Debug/librivregistrar-no.a"
00000b9f (__TEXT,__text) external _regActivate
00000343 (__TEXT,__text) external _regAddActivationInfo
0000052d (__TEXT,__text) external _regAddSKU
00000f13 (__TEXT,__text) external _regDeactivate
000011a5 (__TEXT,__text) external _regGetError
00001143 (__TEXT,__text) external _regGetRegistered
000001a2 (__TEXT,__text) external _regInit
000007fd (__TEXT,__text) external _regPurchaseSKU
000006ef (__TEXT,__text) external _regPurchaseWithKey
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Xcode-users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden