PNG problem - can't open the file

Member
Posts: 61
Joined: 2007.01
Post: #1
Hey,

I'm using the png.c code that OneSadCookie recommends to anyone who posts about textures.

When I try to run my app, I get the error message that it can't open the "texture.png" file.

Maybe this is an Xcode problem (or more precisely a lack of knowledge on my part problem!) but I have the file name specified as "texture.png" in the load_png_image() function call.

texture.png is located in the root of my project folder and then I put a copy in the build folder just in case. Is there a correct place to put resource files like that?

I'm pretty po'd trying to work out what the problem is at this stage, I had expected to have a nice textured quad on my screen but no joy as yet Mad
Quote this message in a reply
Member
Posts: 245
Joined: 2005.11
Post: #2
It's been said many times before, but:
try putting the image in the same folder as your executable.
Alternatively, specify the absolute path to the image. If you're not sure what that is, open the terminal and drag the file into it. The path will appear, and you can copy and paste it into your application. Obviously this is not remotely portable, but will allow you to see your code load the image.
Quote this message in a reply
Moderator
Posts: 1,140
Joined: 2005.07
Post: #3
Putting it in the same folder as your executable won't help. When you open an application, the directory that's set is root by default. Search the forums and you'll find a way to move the current directory to your package directory. It's only been discussed thousands of times. Rasp
Quote this message in a reply
Member
Posts: 61
Joined: 2007.01
Post: #4
Okay so I figured out the directory thing but now when I run a build I'm getting a LOAD of undefined symbols.

Code:
Building target “Shuttles” of project “Shuttles” with configuration “Debug” — (1 error)
    Checking Dependencies        cd /Users/anthonycosgrave/Shuttles
    /usr/bin/gcc-4.0 -o /Users/anthonycosgrave/Shuttles/build/Debug/Shuttles.app/Contents/MacOS/Shuttles -L/Users/anthonycosgrave/Shuttles/build/Debug -F/Users/anthonycosgrave/Shuttles/build/Debug -filelist /Users/anthonycosgrave/Shuttles/build/Shuttles.build/Debug/Shuttles.build/Objects-normal/i386/Shuttles.LinkFileList -framework Carbon -framework GLUT -framework OpenGL -arch i386 -Wl,-Y,1455 -framework Carbon
/usr/bin/ld: Undefined symbols:
_png_create_info_struct
_png_create_read_struct
_png_destroy_read_struct
_png_get_bit_depth
_png_get_color_type
_png_get_image_height
_png_get_image_width
_png_get_valid
_png_init_io
_png_read_image
_png_read_info
_png_read_update_info
_png_set_filler
_png_set_gray_1_2_4_to_8
_png_set_gray_to_rgb
_png_set_palette_to_rgb
_png_set_rgb_to_gray_fixed
_png_set_sig_bytes
_png_set_strip_16
_png_set_strip_alpha
_png_set_tRNS_to_alpha
_png_sig_cmp
/Users/anthonycosgrave/Shuttles/build/Shuttles.build/Debug/Shuttles.build/Objects-normal/i386/main.o reference to undefined _png_create_info_struct
/Users/anthonycosgrave/Shuttles/build/Shuttles.build/Debug/Shuttles.build/Objects-normal/i386/main.o reference to undefined _png_create_read_struct
/Users/anthonycosgrave/Shuttles/build/Shuttles.build/Debug/Shuttles.build/Objects-normal/i386/main.o reference to undefined _png_destroy_read_struct
/Users/anthonycosgrave/Shuttles/build/Shuttles.build/Debug/Shuttles.build/Objects-normal/i386/main.o reference to undefined _png_get_bit_depth
/Users/anthonycosgrave/Shuttles/build/Shuttles.build/Debug/Shuttles.build/Objects-normal/i386/main.o reference to undefined _png_get_color_type
/Users/anthonycosgrave/Shuttles/build/Shuttles.build/Debug/Shuttles.build/Objects-normal/i386/main.o reference to undefined _png_get_image_height
/Users/anthonycosgrave/Shuttles/build/Shuttles.build/Debug/Shuttles.build/Objects-normal/i386/main.o reference to undefined _png_get_image_width
/Users/anthonycosgrave/Shuttles/build/Shuttles.build/Debug/Shuttles.build/Objects-normal/i386/main.o reference to undefined _png_get_valid
/Users/anthonycosgrave/Shuttles/build/Shuttles.build/Debug/Shuttles.build/Objects-normal/i386/main.o reference to undefined _png_init_io
/Users/anthonycosgrave/Shuttles/build/Shuttles.build/Debug/Shuttles.build/Objects-normal/i386/main.o reference to undefined _png_read_image
/Users/anthonycosgrave/Shuttles/build/Shuttles.build/Debug/Shuttles.build/Objects-normal/i386/main.o reference to undefined _png_read_info
/Users/anthonycosgrave/Shuttles/build/Shuttles.build/Debug/Shuttles.build/Objects-normal/i386/main.o reference to undefined _png_read_update_info
/Users/anthonycosgrave/Shuttles/build/Shuttles.build/Debug/Shuttles.build/Objects-normal/i386/main.o reference to undefined _png_set_filler
/Users/anthonycosgrave/Shuttles/build/Shuttles.build/Debug/Shuttles.build/Objects-normal/i386/main.o reference to undefined _png_set_gray_1_2_4_to_8
/Users/anthonycosgrave/Shuttles/build/Shuttles.build/Debug/Shuttles.build/Objects-normal/i386/main.o reference to undefined _png_set_gray_to_rgb
/Users/anthonycosgrave/Shuttles/build/Shuttles.build/Debug/Shuttles.build/Objects-normal/i386/main.o reference to undefined _png_set_palette_to_rgb
/Users/anthonycosgrave/Shuttles/build/Shuttles.build/Debug/Shuttles.build/Objects-normal/i386/main.o reference to undefined _png_set_rgb_to_gray_fixed
/Users/anthonycosgrave/Shuttles/build/Shuttles.build/Debug/Shuttles.build/Objects-normal/i386/main.o reference to undefined _png_set_sig_bytes
/Users/anthonycosgrave/Shuttles/build/Shuttles.build/Debug/Shuttles.build/Objects-normal/i386/main.o reference to undefined _png_set_strip_16
/Users/anthonycosgrave/Shuttles/build/Shuttles.build/Debug/Shuttles.build/Objects-normal/i386/main.o reference to undefined _png_set_strip_alpha
/Users/anthonycosgrave/Shuttles/build/Shuttles.build/Debug/Shuttles.build/Objects-normal/i386/main.o reference to undefined _png_set_tRNS_to_alpha
/Users/anthonycosgrave/Shuttles/build/Shuttles.build/Debug/Shuttles.build/Objects-normal/i386/main.o reference to undefined _png_sig_cmp
collect2: ld returned 1 exit status
        /usr/bin/ld: Undefined symbols:
        _png_create_info_struct
        _png_create_read_struct
        _png_destroy_read_struct
        _png_get_bit_depth
        _png_get_color_type
        _png_get_image_height
        _png_get_image_width
        _png_get_valid
        _png_init_io
        _png_read_image
        _png_read_info
        _png_read_update_info
        _png_set_filler
        _png_set_gray_1_2_4_to_8
        _png_set_gray_to_rgb
        _png_set_palette_to_rgb
        _png_set_rgb_to_gray_fixed
        _png_set_sig_bytes
        _png_set_strip_16
        _png_set_strip_alpha
        _png_set_tRNS_to_alpha
        _png_sig_cmp
        /Users/anthonycosgrave/Shuttles/build/Shuttles.build/Debug/Shuttles.build/Objects-normal/i386/main.o reference to undefined _png_create_info_struct
        /Users/anthonycosgrave/Shuttles/build/Shuttles.build/Debug/Shuttles.build/Objects-normal/i386/main.o reference to undefined _png_create_read_struct
        /Users/anthonycosgrave/Shuttles/build/Shuttles.build/Debug/Shuttles.build/Objects-normal/i386/main.o reference to undefined _png_destroy_read_struct
        /Users/anthonycosgrave/Shuttles/build/Shuttles.build/Debug/Shuttles.build/Objects-normal/i386/main.o reference to undefined _png_get_bit_depth
        /Users/anthonycosgrave/Shuttles/build/Shuttles.build/Debug/Shuttles.build/Objects-normal/i386/main.o reference to undefined _png_get_color_type
        /Users/anthonycosgrave/Shuttles/build/Shuttles.build/Debug/Shuttles.build/Objects-normal/i386/main.o reference to undefined _png_get_image_height
        /Users/anthonycosgrave/Shuttles/build/Shuttles.build/Debug/Shuttles.build/Objects-normal/i386/main.o reference to undefined _png_get_image_width
        /Users/anthonycosgrave/Shuttles/build/Shuttles.build/Debug/Shuttles.build/Objects-normal/i386/main.o reference to undefined _png_get_valid
        /Users/anthonycosgrave/Shuttles/build/Shuttles.build/Debug/Shuttles.build/Objects-normal/i386/main.o reference to undefined _png_init_io
        /Users/anthonycosgrave/Shuttles/build/Shuttles.build/Debug/Shuttles.build/Objects-normal/i386/main.o reference to undefined _png_read_image
        /Users/anthonycosgrave/Shuttles/build/Shuttles.build/Debug/Shuttles.build/Objects-normal/i386/main.o reference to undefined _png_read_info
        /Users/anthonycosgrave/Shuttles/build/Shuttles.build/Debug/Shuttles.build/Objects-normal/i386/main.o reference to undefined _png_read_update_info
        /Users/anthonycosgrave/Shuttles/build/Shuttles.build/Debug/Shuttles.build/Objects-normal/i386/main.o reference to undefined _png_set_filler
        /Users/anthonycosgrave/Shuttles/build/Shuttles.build/Debug/Shuttles.build/Objects-normal/i386/main.o reference to undefined _png_set_gray_1_2_4_to_8
        /Users/anthonycosgrave/Shuttles/build/Shuttles.build/Debug/Shuttles.build/Objects-normal/i386/main.o reference to undefined _png_set_gray_to_rgb
        /Users/anthonycosgrave/Shuttles/build/Shuttles.build/Debug/Shuttles.build/Objects-normal/i386/main.o reference to undefined _png_set_palette_to_rgb
        /Users/anthonycosgrave/Shuttles/build/Shuttles.build/Debug/Shuttles.build/Objects-normal/i386/main.o reference to undefined _png_set_rgb_to_gray_fixed
        /Users/anthonycosgrave/Shuttles/build/Shuttles.build/Debug/Shuttles.build/Objects-normal/i386/main.o reference to undefined _png_set_sig_bytes
        /Users/anthonycosgrave/Shuttles/build/Shuttles.build/Debug/Shuttles.build/Objects-normal/i386/main.o reference to undefined _png_set_strip_16
        /Users/anthonycosgrave/Shuttles/build/Shuttles.build/Debug/Shuttles.build/Objects-normal/i386/main.o reference to undefined _png_set_strip_alpha
        /Users/anthonycosgrave/Shuttles/build/Shuttles.build/Debug/Shuttles.build/Objects-normal/i386/main.o reference to undefined _png_set_tRNS_to_alpha
        /Users/anthonycosgrave/Shuttles/build/Shuttles.build/Debug/Shuttles.build/Objects-normal/i386/main.o reference to undefined _png_sig_cmp
        collect2: ld returned 1 exit status
Build failed (1 error)

Does this mean that I haven't setup the libpng libraries correctly? I ran the install application and it all seemed to work fine. I have included png.h in my project too.

Thanks for any help!
Quote this message in a reply
Luminary
Posts: 5,143
Joined: 2002.04
Post: #5
You need to add the PNG library to your project.
Quote this message in a reply
Member
Posts: 61
Joined: 2007.01
Post: #6
Quote:You need to add the PNG library to your project.

Sorry for such noob questions Blush but a) what is the PNG library and b) how do I add a library to my my project?
Quote this message in a reply
Luminary
Posts: 5,143
Joined: 2002.04
Post: #7
the one you think you installed, that came with png.h, and by dragging it in.
Quote this message in a reply
Post Reply 

Possibly Related Threads...
Thread: Author Replies: Views: Last Post
  Opengl picking problem (zip file) papillon68 1 4,454 Mar 1, 2009 08:49 PM
Last Post: chronus
  Wings3D .obj file -> OpenGL problem WhatMeWorry 21 16,165 Apr 24, 2007 06:11 AM
Last Post: ThemsAllTook
  file.ai -> Wings3D problem WhatMeWorry 2 2,921 Jan 3, 2006 05:30 PM
Last Post: WhatMeWorry
  New Computer == Open Gl code problem KiroNeem 4 3,229 Mar 31, 2005 09:40 AM
Last Post: KiroNeem