Guidance
指路人
g.yi.org
Guidance Forums / wxWidgets (wxWindows) in C++ / Problems using pictures with wxWindows

Register 
注册
Search 搜索
首页 
Home Home
Software
Upload

  
Forum List • Thread List • Reply • Refresh • New Topic • Search • Previous • Next First 1 Last
Message1. Problems using pictures with wxWindows
#2347
Posted by: Adrian 2003-07-02 07:02:31
Hi all,

This is my first post here.  I'm new to C++ and wxWindows.  I have been working through the wxWindows turtorial and the samples supplied with wxWindows.  I'm trying to use png pictures (and other formats would be good to) in my application but am having no success.  I think it is to do with not having the right library files.  Could someone out there please lend a hand to a beginner.  I will post you a part of my app with the line that causes the problem and the error message I get.

bool MyApp::OnInit()
{
   // Load in the image handlers - Not working just yet
  
    wxImage::AddHandler( new wxPNGHandler ); // this is the problem
      

   // create the main application window
    MyFrame *frame = new MyFrame("Minimal wxWindows App",wxPoint(0,0), wxSize(450,340));

    frame->Show(TRUE);
   frame->SetStatusText("Welcome");  // set the welcome message in the statusbar
  
   //SetTopWindow(frame)
   
   return TRUE;
}

Error message

Compiler: Default compiler
Building Makefile: "C:Dev-CppprojectsprogramMakefile.win"
Executing  make...
make.exe -f "C:Dev-CppprojectsprogramMakefile.win" all
g++.exe -c main.cpp -o main.o -I"C:/Dev-Cpp/include/c++"  -I"C:/Dev-Cpp/include/c++/mingw32"  -I"C:/Dev-Cpp/include/c++/backward"  -I"C:/Dev-Cpp/include" --pipe -D_X86_=1 -DWIN32 -D_WIN32 -DWINVER=0x0400 -D__WIN95__ -D__GNUWIN32__ -D__WIN32__ -mthreads -DSTRICT  -D__WXMSW__ -D__WINDOWS__ -Wall -fno-pcc-struct-return -O2 -fno-rtti -fno-exceptions 

g++.exe main.o MyFrame.o program_private.res -o "program.exe" -L"C:/Dev-Cpp/lib" -mwindows -lwxmswu -lstdc++ -lgcc -lodbc32 -lwsock32 -lwinspool -lwinmm -lshell32 -lcomctl32 -lctl3d32 -lodbc32 -ladvapi32 -lodbc32 -lwsock32 -lopengl32 -lglu32 -lole32 -loleaut32 -luuid

C:/Dev-Cpp/lib/libwxmswu.a(imagpng.o)(.text+0xeb):imagpng.cpp: undefined reference to `png_get_io_ptr'
C:/Dev-Cpp/lib/libwxmswu.a(imagpng.o)(.text+0x11b):imagpng.cpp: undefined reference to `png_get_io_ptr'
C:/Dev-Cpp/lib/libwxmswu.a(imagpng.o)(.text+0x14c):imagpng.cpp: undefined reference to `png_get_io_ptr'
C:/Dev-Cpp/lib/libwxmswu.a(imagpng.o)(.text+0x1bb):imagpng.cpp: undefined reference to `png_get_io_ptr'
C:/Dev-Cpp/lib/libwxmswu.a(imagpng.o)(.text+0x2ca):imagpng.cpp: undefined reference to `png_create_read_struct'
C:/Dev-Cpp/lib/libwxmswu.a(imagpng.o)(.text+0x331):imagpng.cpp: undefined reference to `png_destroy_read_struct'
C:/Dev-Cpp/lib/libwxmswu.a(imagpng.o)(.text+0x35d):imagpng.cpp: undefined reference to `png_destroy_read_struct'
C:/Dev-Cpp/lib/libwxmswu.a(imagpng.o)(.text+0x3b8):imagpng.cpp: undefined reference to `png_set_error_fn'
C:/Dev-Cpp/lib/libwxmswu.a(imagpng.o)(.text+0x3cd):imagpng.cpp: undefined reference to `png_set_read_fn'
C:/Dev-Cpp/lib/libwxmswu.a(imagpng.o)(.text+0x3da):imagpng.cpp: undefined reference to `png_create_info_struct'
C:/Dev-Cpp/lib/libwxmswu.a(imagpng.o)(.text+0x418):imagpng.cpp: undefined reference to `png_read_info'
C:/Dev-Cpp/lib/libwxmswu.a(imagpng.o)(.text+0x445):imagpng.cpp: undefined reference to `png_get_IHDR'
C:/Dev-Cpp/lib/libwxmswu.a(imagpng.o)(.text+0x46b):imagpng.cpp: undefined reference to `png_set_strip_16'
C:/Dev-Cpp/lib/libwxmswu.a(imagpng.o)(.text+0x478):imagpng.cpp: undefined reference to `png_set_packing'
C:/Dev-Cpp/lib/libwxmswu.a(imagpng.o)(.text+0x48d):imagpng.cpp: undefined reference to `png_get_valid'
C:/Dev-Cpp/lib/libwxmswu.a(imagpng.o)(.text+0x4ac):imagpng.cpp: undefined reference to `png_set_filler'
C:/Dev-Cpp/lib/libwxmswu.a(imagpng.o)(.text+0x534):imagpng.cpp: undefined reference to `png_read_image'
C:/Dev-Cpp/lib/libwxmswu.a(imagpng.o)(.text+0x546):imagpng.cpp: undefined reference to `png_read_end'
C:/Dev-Cpp/lib/libwxmswu.a(imagpng.o)(.text+0x55b):imagpng.cpp: undefined reference to `png_destroy_read_struct'
C:/Dev-Cpp/lib/libwxmswu.a(imagpng.o)(.text+0x72b):imagpng.cpp: undefined reference to `png_set_expand'
C:/Dev-Cpp/lib/libwxmswu.a(imagpng.o)(.text+0x742):imagpng.cpp: undefined reference to `png_set_expand'
C:/Dev-Cpp/lib/libwxmswu.a(imagpng.o)(.text+0x759):imagpng.cpp: undefined reference to `png_set_expand'

C:/Dev-Cpp/lib/libwxmswu.a(imagpng.o)(.text+0x7aa):imagpng.cpp: undefined reference to `png_create_write_struct'
C:/Dev-Cpp/lib/libwxmswu.a(imagpng.o)(.text+0x808):imagpng.cpp: undefined reference to `png_set_error_fn'
C:/Dev-Cpp/lib/libwxmswu.a(imagpng.o)(.text+0x812):imagpng.cpp: undefined reference to `png_create_info_struct'
C:/Dev-Cpp/lib/libwxmswu.a(imagpng.o)(.text+0x83f):imagpng.cpp: undefined reference to `png_destroy_write_struct'
C:/Dev-Cpp/lib/libwxmswu.a(imagpng.o)(.text+0x85e):imagpng.cpp: undefined reference to `png_set_write_fn'
C:/Dev-Cpp/lib/libwxmswu.a(imagpng.o)(.text+0x89c):imagpng.cpp: undefined reference to `png_set_IHDR'
C:/Dev-Cpp/lib/libwxmswu.a(imagpng.o)(.text+0x8c0):imagpng.cpp: undefined reference to `png_set_sBIT'
C:/Dev-Cpp/lib/libwxmswu.a(imagpng.o)(.text+0x8d2):imagpng.cpp: undefined reference to `png_write_info'
C:/Dev-Cpp/lib/libwxmswu.a(imagpng.o)(.text+0x8de):imagpng.cpp: undefined reference to `png_set_shift'
C:/Dev-Cpp/lib/libwxmswu.a(imagpng.o)(.text+0x8e8):imagpng.cpp: undefined reference to `png_set_packing'
C:/Dev-Cpp/lib/libwxmswu.a(imagpng.o)(.text+0xa07):imagpng.cpp: undefined reference to `png_write_rows'
C:/Dev-Cpp/lib/libwxmswu.a(imagpng.o)(.text+0xa3d):imagpng.cpp: undefined reference to `png_write_end'
C:/Dev-Cpp/lib/libwxmswu.a(imagpng.o)(.text+0xa4f):imagpng.cpp: undefined reference to `png_destroy_write_struct'
C:/Dev-Cpp/lib/libwxmswu.a(imagpng.o)(.text+0xa66):imagpng.cpp: undefined reference to `png_destroy_write_struct'

make.exe: *** [program.exe] Error 1

Execution terminated


Also, I notice in the wxWindows docs the follow:

::wxInitAllImageHandlers
void wxInitAllImageHandlers()

Initializes all available image handlers. For a list of available handlers, see wxImage.

See also

wxImage, wxImageHandler

Include files

<wx/image.h>

How would you use this in your program so that all images available can be used.

Thank you for any help you can give,

Adrian
Message2. Re: Problems using pictures with wxWindows
#2349
Posted by: guidance 2003-07-02 11:36:15
I found libpng.a in dev-cpp/lib directory(http://g.yi.org/_scripts/file.php?f=2625&r=401#3949), try to add -lpng into your link options.
Message3. Re: Problems using pictures with wxWindows
#2356
Posted by: Adrian 2003-07-03 09:16:02
Thank you Guidance for your reply. 

I did as you suggested but I got the following error (slightly different from the previous one).  What else can I do?  Here is a copy of my links:

-lwxmswu -lstdc++ -lgcc -lodbc32 -lwsock32 -lwinspool -lwinmm -lshell32 -lcomctl32 -lctl3d32 -lodbc32 -ladvapi32 -lodbc32 -lwsock32 -lopengl32 -lglu32 -lole32 -loleaut32 -luuid -lpng


Here is the error message:

Compiler: Default compiler
Building Makefile: "C:Dev-CppprojectsprogramMakefile.win"
Executing  make...
make.exe -f "C:Dev-CppprojectsprogramMakefile.win" all
windres.exe -i program_private.rc -I rc -o program_private.res -O coff  --include-dir C:/Dev-Cpp/include

g++.exe main.o MyFrame.o program_private.res -o "program.exe" -L"C:/Dev-Cpp/lib" -mwindows -lwxmswu -lstdc++ -lgcc -lodbc32 -lwsock32 -lwinspool -lwinmm -lshell32 -lcomctl32 -lctl3d32 -lodbc32 -ladvapi32 -lodbc32 -lwsock32 -lopengl32 -lglu32 -lole32 -loleaut32 -luuid ../../lib/libzlib.a ../../lib/libpng.a

../../lib/libpng.a(pngwrite.o)(.text+0x1289):pngwrite.c: undefined reference to `deflate'
../../lib/libpng.a(pngwrite.o)(.text+0x1461):pngwrite.c: undefined reference to `deflateEnd'
../../lib/libpng.a(pngread.o)(.text+0x2e4):pngread.c: undefined reference to `inflateInit_'
../../lib/libpng.a(pngread.o)(.text+0x69a):pngread.c: undefined reference to `inflateInit_'
../../lib/libpng.a(pngread.o)(.text+0x1052):pngread.c: undefined reference to `inflate'
../../lib/libpng.a(pngread.o)(.text+0x1ca3):pngread.c: undefined reference to `inflateEnd'
../../lib/libpng.a(png.o)(.text+0x30d):png.c: undefined reference to `crc32'
../../lib/libpng.a(png.o)(.text+0x365):png.c: undefined reference to `crc32'
../../lib/libpng.a(png.o)(.text+0xdae):png.c: undefined reference to `inflateReset'
../../lib/libpng.a(pngwutil.o)(.text+0x299):pngwutil.c: undefined reference to `deflate'
../../lib/libpng.a(pngwutil.o)(.text+0x3b9):pngwutil.c: undefined reference to `deflate'
../../lib/libpng.a(pngwutil.o)(.text+0xaa6):pngwutil.c: undefined reference to `deflateInit2_'
../../lib/libpng.a(pngwutil.o)(.text+0x2d69):pngwutil.c: undefined reference to `deflate'
../../lib/libpng.a(pngwutil.o)(.text+0x3e46):pngwutil.c: undefined reference to `deflate'
../../lib/libpng.a(pngwutil.o)(.text+0x613):pngwutil.c: undefined reference to `deflateReset'
../../lib/libpng.a(pngwutil.o)(.text+0x2d9e):pngwutil.c: undefined reference to `deflateReset'
../../lib/libpng.a(pngrutil.o)(.text+0x46c):pngrutil.c: undefined reference to `inflate'
../../lib/libpng.a(pngrutil.o)(.text+0x508):pngrutil.c: undefined reference to `inflateReset'
../../lib/libpng.a(pngrutil.o)(.text+0x72e):pngrutil.c: undefined reference to `inflateReset'
../../lib/libpng.a(pngrutil.o)(.text+0x4574):pngrutil.c: undefined reference to `inflate'
../../lib/libpng.a(pngrutil.o)(.text+0x4606):pngrutil.c: undefined reference to `inflateReset'

make.exe: *** [program.exe] Error 1

Execution terminated



Thanks for your help

Adrian
Message4. Re: Problems using pictures with wxWindows
#2361
Posted by: 2003-07-04 19:35:07
Add -lzlib, too...

upcase
Message5. Re: It now works!!!
#2362
Posted by: Adrian 2003-07-05 15:32:20
Thank you very much upcase.  That worked.  A simple anwer to annoying problem.

Adrian
Forum List • Thread List • Reply • Refresh • New Topic • Search • Previous • Next First 1 Last
掌柜推荐
 
 
 
 
 
 
 
 
 
 
 
 
© Fri 2023-1-27  Guidance Laboratory Inc.
Email:webmaster1g.yi.org Hits:0