Xcode and library search paths
This might just be a stupid Xcode user error on my part, but...
I've downloaded the libpng library (PNG file format) and I'm trying to
get an Xcode project of mine to use it. The compilation is fine, but
I get a bunch of
/usr/bin/ld: Undefined symbols:
_png_create_struct
_png_create_struct_2
_png_destroy_struct
_png_destroy_struct_2
_png_error
_png_free
_png_malloc
_png_warning
Ok, I did some googling and came across a Darwin example which used
LIBRARIES += -L/sw/lib -lpng -lz in the make file.
and looking at my "build results" there was no entry like this. So I went
into Xcode, selected my project folder and the info button. Then I selected
the build tab and the Library Search Paths collection.
I entered -L/sw/lib -lpng in the field and then left the build settings.
I recompiled and it still fails. I go into Build>Build Results and when I show
the transcript there is no -L/sw/lib -lpng string.
Anybody know why my new setting in the build options isn't making its way
to the actual build?
I've downloaded the libpng library (PNG file format) and I'm trying to
get an Xcode project of mine to use it. The compilation is fine, but
I get a bunch of
/usr/bin/ld: Undefined symbols:
_png_create_struct
_png_create_struct_2
_png_destroy_struct
_png_destroy_struct_2
_png_error
_png_free
_png_malloc
_png_warning
Ok, I did some googling and came across a Darwin example which used
LIBRARIES += -L/sw/lib -lpng -lz in the make file.
and looking at my "build results" there was no entry like this. So I went
into Xcode, selected my project folder and the info button. Then I selected
the build tab and the Library Search Paths collection.
I entered -L/sw/lib -lpng in the field and then left the build settings.
I recompiled and it still fails. I go into Build>Build Results and when I show
the transcript there is no -L/sw/lib -lpng string.
Anybody know why my new setting in the build options isn't making its way
to the actual build?
because you put it in the wrong place 
If you'd put those in the "other linker flags", and got libpng from fink (which is what puts it in /sw/lib) then it'd work.
Dragging libpng.a from libpng's build directory into your project should be sufficient to have Xcode do the right thing.

If you'd put those in the "other linker flags", and got libpng from fink (which is what puts it in /sw/lib) then it'd work.
Dragging libpng.a from libpng's build directory into your project should be sufficient to have Xcode do the right thing.
Thanks!
Silly me. Since libpng is a library, i thought i should've updated Search Library Path. Whatever lead me to think that
Maybe one is for compile time and the other is for the link phase?
Silly me. Since libpng is a library, i thought i should've updated Search Library Path. Whatever lead me to think that
Maybe one is for compile time and the other is for the link phase?
Entries in the "library search path" field have -L stuck on the front, so if you put "/sw/lib" into the library search paths, it's like adding "-L/sw/lib" to the GCC command-line.
Libraries you add to your project automatically get the "lib" knocked off the beginning and the ".a" or ".dylib" knocked off the end, and "-l" added in front, so adding libpng.a to your project is like adding "-lpng" to the GCC command-line. However, adding libpng.a to your project should automatically configure the library search paths too.
Libraries you add to your project automatically get the "lib" knocked off the beginning and the ".a" or ".dylib" knocked off the end, and "-l" added in front, so adding libpng.a to your project is like adding "-lpng" to the GCC command-line. However, adding libpng.a to your project should automatically configure the library search paths too.
Thanks again!
I just came back from perusing the GCC web site. started to look at the documentation for gcc's options for linking and preprocessing.
There's alot of options out there
Should of started here instead of Xcode's documentation.
I just came back from perusing the GCC web site. started to look at the documentation for gcc's options for linking and preprocessing.
There's alot of options out there
Should of started here instead of Xcode's documentation.
Possibly Related Threads...
| Thread: | Author | Replies: | Views: | Last Post | |
| XCode doesn't realize a library has changed unless you force your project to build. | XSTNX | 6 | 4,992 |
Jun 8, 2009 10:25 AM Last Post: XSTNX |
|
| xcode won't link my .a library... | chenjin824 | 0 | 3,208 |
Jun 6, 2009 07:20 PM Last Post: chenjin824 |
|
| framework search path | scarypajamas | 0 | 2,843 |
Dec 23, 2008 01:50 PM Last Post: scarypajamas |
|
| xcode instruments screwing up paths | Najdorf | 4 | 4,084 |
Sep 7, 2008 02:08 PM Last Post: OneSadCookie |
|
| Regular Expression Search And Replace in Xcode | Nick | 4 | 3,913 |
Nov 25, 2006 03:47 PM Last Post: Nick |
|

