# Jpeg support in PHP

## Tesla2k

Hi,

I am missing jpeg support in php (gd). I've installed libjpeg, libgd, png support works fine, but during the configure of mod_php it says jpeg support... no.

I've got jpeg in my use flags (/etc/make.conf)

I am runngin gentoo 1.4 

anyone an idea ?

thx

----------

## nitro322

I have the EXACT same problem under Gentoo 1.2.  I tried this with both libgd 1.8.3 and 2.0.1 and in both cases I'm only able to output png images, no jpegs.  Anyone know what the problem might be?  Thanks.

----------

## rac

Would it be possible for you to track down the section of config.log where configure determines that there is no jpeg support and post it?

----------

## nitro322

 *rac wrote:*   

> Would it be possible for you to track down the section of config.log where configure determines that there is no jpeg support and post it?

 

Will have to check on my other computer later on today.  Where can I find that log file?  I still don't have the whole portage/ebuild layout down yet.  Thanks.

----------

## rac

 *nitro322 wrote:*   

> Where can I find that log file?

 

Somewhere under /var/tmp/portage/mumble-1.0-r1/work/mumble, where the "mumble" parts correspond to the ebuild you're working on.

----------

## nitro322

It looks like the problem is occuring during the compilation of php.  From emerge output:

```
<snip>

checking for GD support... yes

checking whether to enable truetype string function in GD... no

checking for the location of libjpeg... no

If configure fails try --with-jpeg-dir=<DIR>

checking for the location of libpng... no

If configure fails try --with-png-dir=<DIR> and --with-zlib-dir=<DIR>

checking for the location of libXpm... yes

checking for XpmFreeXpmImage in -lXpm... yes

checking for freetype(2)... no

If configure fails try --with-freetype-dir=<DIR>

checking for FreeType 1.x support... no

checking for T1lib support... no

checking for gdImageString16 in -lgd... yes

checking for gdImagePaletteCopy in -lgd... yes

checking for gdImageCreateFromPng in -lgd... no

checking for gdImageCreateFromGif in -lgd... no

checking for gdImageGif in -lgd... no

checking for gdImageWBMP in -lgd... yes

checking for gdImageCreateFromJpeg in -lgd... no

checking for gdImageCreateFromXpm in -lgd... yes

checking for gdImageCreateFromGd2 in -lgd... yes

checking for gdImageCreateTrueColor in -lgd... no

checking for gdImageSetTile in -lgd... yes

checking for gdImageSetBrush in -lgd... yes

checking for gdImageStringTTF in -lgd... no

checking for gdImageStringFT in -lgd... no

checking for gdImageStringFTEx in -lgd... no

checking for gdImageColorClosestHWB in -lgd... yes

checking for gdImageColorResolve in -lgd... yes

checking for gdImageGifCtx in -lgd... no

</snip>
```

and from php's config.log:

```
<snip>

/usr/lib/libgd.a(gd_jpeg.o): In function `gdImageJpegCtx':

gd_jpeg.o(.text+0x3e): undefined reference to `jpeg_std_error'

gd_jpeg.o(.text+0xa0): undefined reference to `jpeg_CreateCompress'

gd_jpeg.o(.text+0xda): undefined reference to `jpeg_set_defaults'

gd_jpeg.o(.text+0xfa): undefined reference to `jpeg_set_quality'

gd_jpeg.o(.text+0x116): undefined reference to `jpeg_simple_progression'

gd_jpeg.o(.text+0x175): undefined reference to `jpeg_destroy_compress'

gd_jpeg.o(.text+0x193): undefined reference to `jpeg_start_compress'

gd_jpeg.o(.text+0x26b): undefined reference to `jpeg_write_marker'

gd_jpeg.o(.text+0x313): undefined reference to `jpeg_write_scanlines'

gd_jpeg.o(.text+0x35a): undefined reference to `jpeg_finish_compress'

gd_jpeg.o(.text+0x363): undefined reference to `jpeg_destroy_compress'

/usr/lib/libgd.a(gd_jpeg.o): In function `gdImageCreateFromJpegCtx':

gd_jpeg.o(.text+0x3d1): undefined reference to `jpeg_std_error'

gd_jpeg.o(.text+0x450): undefined reference to `jpeg_CreateDecompress'

gd_jpeg.o(.text+0x46f): undefined reference to `jpeg_read_header'

gd_jpeg.o(.text+0x538): undefined reference to `jpeg_start_decompress'

gd_jpeg.o(.text+0x676): undefined reference to `jpeg_read_scanlines'

gd_jpeg.o(.text+0x6cd): undefined reference to `jpeg_finish_decompress'

gd_jpeg.o(.text+0x6f4): undefined reference to `jpeg_destroy_decompress'

gd_jpeg.o(.text+0x733): undefined reference to `jpeg_destroy_decompress'

/usr/lib/libgd.a(gd_jpeg.o): In function `fatal_jpeg_error':

gd_jpeg.o(.text+0x970): undefined reference to `jpeg_destroy'

/usr/lib/libgd.a(gd_jpeg.o): In function `jpeg_gdIOCtx_src':

gd_jpeg.o(.text+0xa66): undefined reference to `jpeg_resync_to_restart'

collect2: ld returned 1 exit status

configure: failed program was:

#line 25191 "configure"

#include "confdefs.h"

/* Override any gcc2 internal prototype to avoid an error.  */

/* We use char because int might match the return type of a gcc2

    builtin and then its argument prototype would still apply.  */

char gdImageCreateFromJpeg();

</snip>
```

Actually, this is pretty messed up.  I get the same errors with png, but png works and jpeg doesn't.  Also, from looking at the initial output, a whole lot of stuff wasn't found/supported that should be - truetype, freetype, and jpeg among them.  I compiled all of this from source on a RedHat box a couple weeks ago, so I know it should be playing nicely together.  Don't know what else I can do, though.  I've recompiled every version and in every order I could think of.  Any suggestions from here?  Thanks.

----------

## Tesla2k

i solved the problem. a look into the ebuild file offered, that you have to remove pdflib from your use flags. add -pdflib to use in make.conf then it will work.

----------

## rac

Nitro322, did Tesla2k's advice work for you, too?

----------

## nitro322

umm, not really.  Now I get this when compiling php:

```
configure: error: Unable to find libgd.(a|so) anywhere under /usr/local /usr

!!! ERROR: The ebuild did not complete successfully.

!!! Function src_compile, Line 166, Exitcode 1

!!! bad ./configure
```

I tried looking at the php ebuild, but I don't really know what to look for, and all the references to libgd that I saw looked ok to me.  On the plus side, it did detect that jpeg was available.  Now I just need to get it to compile...   :Smile:   Any more suggestions?  Thanks allot with all the help, by the way.

----------

## rac

Is https://bugs.gentoo.org/show_bug.cgi?id=5444 relevant?

----------

## nitro322

it does look pretty relevant.  I'll take a closer look in the morning and see if I can figure it out.  Thanks.

----------

## roman

Solution is simple...

there is section in ebuild file:

```

if ["'use pdflib'"] ; then

   myconf="${myconf} --with-pdflib=/usr"

else

   use jpeg && myconf="${myconf} --with-jpeg-dir=/usr/lib"

   use tiff && myconf="${myconf} --with-tiff-dir=/usr"

fi

```

as u can see, if u have USE pdf enabled, jpeg will not be included...

it's probably bug of ebuild...

So I've copied two lines

```

   use jpeg && myconf="${myconf} --with-jpeg-dir=/usr/lib"

   use tiff && myconf="${myconf} --with-tiff-dir=/usr"

```

right after all "use xxx" lines right before this if section and voila,

all is working now...

Remember that each emerge rsync will destroy this change...

Hope this helps...

----------

## nitro322

ok, I'm having some massive problems now.  Roman, I tried your suggestion, but I still got the libgd.(a|so) error I posted earlier.  After a little investigation, I found that /usr/lib/libgd.so was a symlink pointing to something really long and really wrong.  I deleted it and created a new one pointing to /usr/lib/libgd.so.2.0.0 and that worked fine.

However, when I try to compile PHP now I keep getting mysql errors.  It finds that it's supported when checking for it, but a little further down it craps out with a couple errors relating to it (sorry, this happens on another computer so I don't have the error messages at hand).  I tried recompiling MySQL, but no luck.  I've tried messing with the PHP ebuild some more, but still no luck.  I've tried unmerging and re-emerging everything from jpeg and libpng to libgd and mysql to php and apache, but I cannot get php to build any more.

I'll try an emerge rsync tonight and start everything over - hopefully it'll work everything out.  If not, though, I'm sure I'll be back in the morning.  I really need to get this working ASAP for my senior project.  If it continues to fail I'll have to just switch back to RedHat or something for the time being, but I'd REALLY hate to do that after spending so much time getting Gentoo working beautifully on it.  Anyway, thanks for the help.  I'll let you know how it goes.  Oh, and any additional suggestions, no matter how insignificant, are always welcome.

----------

## rac

nitro322, once you have the text of the mysql error messages, please post them, and probably in a separate thread (maybe under Portage & Programming).  People that might be able to help you might not find it under this JPEG thread title.

----------

