Re: [GD-DEVEL] gd with mingw gcc
[email protected] (Patolfo)
| Newsgroups | php.gd.devel |
|---|---|
| Message-ID | <[email protected]> |
Many thanks man, that hint hit the spot, I just modified the linker options and all went like a charm: Besides I added some more libraries to the linker options the ones mentioned in my erlier e-mail, and the example runs now. Bill Frost wrote: > Hi Patolfo, > > This all works with Code::Blocks. If this list allows attachments, I've > included the PNG it produces. > > I have the same version of the Windows binary you have and I use MinGW. Just > follow these steps (then clean up the DLLs and .h files you sprayed > everywhere a bit earlier!!!): > > Assuming your GDLIB is in C:\GDLIB and you have Code::Blocks installed: > > 1 Create a new project in Code::Blocks - a console app is fine. > 2 Copy the bgd.dll, gd.h, gdfx.h and gd_io.h files into the project > directory (there are other ways of doings this I know). > 3 From Code::Blocks, click 'Project-Build Options', then the 'Linker > Settings' tab. > 4 Click 'Add' and navigate your file system to and select > C:\GDLIB\lib\bgd.lib. When asked, keep it as a relative path. > 5 Compile. As this is a console app, you only see the cmd window, so > navigate to the project directory using Explorer and click on test.png. > > > > Directory of C:\Documents and Settings\Bill Frost\My > Documents\Source\deleteme > > 09/01/2008 09:32 PM <DIR> . > 09/01/2008 09:32 PM <DIR> .. > 09/01/2008 09:14 PM <DIR> bin > 09/01/2008 09:14 PM <DIR> obj > 24/06/2007 04:49 PM 765,952 bgd.dll > 09/01/2008 09:12 PM 1,074 deleteme.cbp > 09/01/2008 09:17 PM 465 deleteme.depend > 24/06/2007 04:49 PM 32,588 gd.h > 24/06/2007 04:49 PM 2,396 gdfx.h > 24/06/2007 04:49 PM 1,154 gd_io.h > 09/01/2008 09:14 PM 1,199 main.cpp > 09/01/2008 09:28 PM 113 test.png > > > > -----Original Message----- > From: Patolfo [mailto:[email protected]] > Sent: Wednesday, 9 January 2008 2:33 AM > To: Bill Frost > Cc: [email protected] > Subject: Re: [GD-DEVEL] gd with mingw gcc > > Hey dude thx for asking, well I am trying both *cough* first tried with > code blocks but did not do the trcik so I swtich back to command line, > from dos console, and well it did not work either. > > The example I'm trying is the first one, sadly yet rather simply at > time compile is where the problems arise, let me put you the console output: > > Firstly, I forgot, I copy bgd.dll to every possible location I could > imagine :) > inside mingw in the bin lib and inlude folders, yeah this is paranoia, > and also to the windows/system folder as well as in the working directory. > > This binary was what I got from: > http://www.libgd.org/releases/oldreleases/gd-2.0.34-win32.zip > from the libgd.org site. > > The source code to create a png example: > /* Bring in gd library functions */ > #include "gd.h" > /* Bring in standard I/O so we can output the PNG to a file */ > #include <stdio.h> > int main() { > /* Declare the image */ > gdImagePtr im; > /* Declare output files */ > FILE *pngout; > /* Declare color indexes */ > int black; > int white; > /* Allocate the image: 64 pixels across by 64 pixels tall */ > im = gdImageCreate(64, 64); > /* Allocate the color black (red, green and blue all minimum). > Since this is the first color in a new image, it will > be the background color. */ > black = gdImageColorAllocate(im, 0, 0, 0); > /* Allocate the color white (red, green and blue all maximum). */ > white = gdImageColorAllocate(im, 255, 255, 255); > /* Draw a line from the upper left to the lower right, > using white color index. */ > gdImageLine(im, 0, 0, 63, 63, white); > /* Open a file for writing. "wb" means "write binary", important > under MSDOS, harmless under Unix. */ > pngout = fopen("test.png", "wb"); > /* Output the image to the disk file in PNG format. */ > gdImagePng(im, pngout); > /* Close the files. */ > fclose(pngout); > /* Destroy the image in memory. */ > gdImageDestroy(im); > } > > The compilation command: > g++ ${file_name.c} -lgd -lpng -lz -lm -o $(file_name) > I tried gcc but the error was the same > > The output says the following: > /mingw/lib/libmingw32.a(main.o):main.c:(.text+0x104): undefined > reference to 'WinMain@16' > > If some one could send me a working example, please do not hesiatate > > Bill Frost wrote: > >> Hi Patolfo, >> >> I assume you have your own source code with calls to the examples and now >> wish to compile it? >> >> If so, are you using command line or an IDE? I had a little bit of trial >> > and > >> error configuring Code::Blocks to run it when I first started 9 months ago >> but it's been flawless ever since and it is a wonderful product! >> >> If you post details about the environment you are working in I'm sure >> someone can help. >> >> I've been using GD to generate graphs of altitude, power, gradient and >> velocity and also latitude / longitude maps from raw GPS data using C++ >> > and > >> Code::Blocks and it is a wonderful product. >> >> Cheers, >> >> Bill >> >> >> >> -----Original Message----- >> From: Patolfo [mailto:[email protected]] >> Sent: Tuesday, 8 January 2008 9:56 AM >> To: Pierre >> Cc: [email protected] >> Subject: Re: [GD-DEVEL] gd with mingw gcc >> >> Hi pierre thx for answering, in fact nope I did not comile my self, too >> much trouble , I donwloaded binary versions precompiled for windows, >> from the sourceforge site, I extracted the files into mingw installation >> folder, the problem is that when I tried to compile the examples, the >> compiler stopped because can not find lgd library, and there is where I >> am stuck. Do not know what else to do. >> >> Pierre wrote: >> >> >>> HI, >>> >>> On Jan 6, 2008 9:49 PM, Patolfo Nery Velya <[email protected]> wrote: >>> >>> >>> >>>> HI guys good day, >>>> well I have downloaded the latest windows version of gd, but when trying >>>> >>>> >> to >> >> >>>> compile says that the compiler can not find lgd >>>> >>>> i am working with mingw and gcc under windows, did you have the same >>>> >>>> >> problem >> >> >>>> and how did you solve it >>>> >>>> >>>> >>> Do you compile GD yourself? >>> >>> >>> >>> >> >> > > > > ------------------------------------------------------------------------ >