[NetBehaviour] Several hundred words of warning^d^d^d^d^d^d^dextreme wisdom for those wishing to build jpeginfo to install in their ${HOME}

James Morris jwm.art.net at gmail.com
Thu Apr 14 03:46:09 CEST 2011


A word of warning for those wishing to build jpeginfo to install in
their ${HOME}

Say you log into your website shell account via SSH to edit the
index.html file in the web document root. You need to know the
dimensions of an image, but can't be bothered to remember how to do it
in PHP or whatever. So you try the commandline program jpeginfo but
it's not installed on the server. However, your shell account gives
you access to the tools to compile software from source.

So you go to your little smartphones web browser and find the URL to
download the sourcecode to jpeginfo. You work at a factory, at a
semi-automatic moulding machine which gives you 10 seconds of freedom
every minute or so to do things such as this. You switch back to BBSSH
and paste the URL at the end of wget and the server downloads jpeginfo
into your ${HOME}.

Having done quite a lot of software compiling you know that you need
to pass --prefix=${HOME}/somedirectory to ./configure to tell it where
you want to install the software. You decide to not break convention
and settle on ./configure --prefix=${HOME}/usr and then mkdir ~/usr.
Of course, it takes around 15 minutes to work all this stuff out and
arrive at the command.

The first hurdle arrives:
checking for jpeg_read_header in -ljpeg... no
Cannot find libjpeg or you have too old version (v6 or later required).

Oh dear. jpeginfo depends on libjpeg. so switch to browser and locate
libjpeg source code. Its called jpegsrc. You hope that jpegsrc depends
on no other and it does not. ./configure --prefix=${HOME}/usr works
like a charm as does make && make install. ls ~/usr proves it showing
'include' 'lib' 'share'.

Back to jpeginfo then. You know now that you must tell ./configure
where you've put libjpeg and hope it finds it. ./configure --help |
less eventually yields the how. You try the command ./configure
--prefix=${HOME}/usr --with-libjpeg=${HOME}/usr/lib but it informs
you:

Cannot find jpeglib.h  You need libjpeg v6 (or later).

Dammit. I must need to tell it where the includes are. Scan
./configure --help | less again shows there's no way to do that. Of
course! Descet too far into path. RE ./configure --prefix=${HOME}/usr
--with-libjpeg=${HOME}/usr && make

gcc  -g -O2 -I/home/jwmorris/usr/include -DHAVE_CONFIG_H   -c -o
jpeginfo.o jpeginfo.c
In file included from jpeginfo.c:25:
md5.h:10: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’
before ‘!’ token
md5.h:32: warning: ‘struct MD5Context’ declared inside parameter list
md5.h:32: warning: its scope is only this definition or declaration,
which is probably not what you want
md5.h:33: warning: ‘struct MD5Context’ declared inside parameter list
md5.h:34: warning: ‘struct MD5Context’ declared inside parameter list
md5.h:35: error: expected ‘)’ before ‘buf’
jpeginfo.c: In function ‘main’:
jpeginfo.c:158: error: invalid application of ‘sizeof’ to incomplete
type ‘MD5_CTX’
jpeginfo.c:286: warning: passing argument 1 of ‘MD5Init’ from
incompatible pointer type
jpeginfo.c:287: warning: passing argument 1 of ‘MD5Update’ from
incompatible pointer type
jpeginfo.c:288: warning: passing argument 2 of ‘MD5Final’ from
incompatible pointer type
make: *** [jpeginfo.o] Error 1

but remember this is on a smartphone which dislikes the dandy use of
quotes shown above, adding to the mind-boggling obscurity (ok pretend
i don't understand it). I look in md5.h | less. cat -n md5.h | less.
line 10:

    4  #if SIZEOF_LONG == 4
     5  typedef unsigned long uint32;
     6  #else
     7  #if SIZEOF_INT == 4
     8  typedef unsigned int uint32;
     9  #else
    10  Congratulations!  You get to rewrite this code so that it does
not require
    11  a 32-bit integer type!  (Or maybe you just need to reconfigure.)
    12  #endif
    13  #endif

how bamboozling! grep SIZEOF config.h

#define SIZEOF_INT 0
#define SIZEOF_LONG 0

But no! How can this be?

You take a break and setup camp in your email inbox. There's just
under two more hours at work left. The phone battery is low and so the
smartphone being smart turns off radio reception meaning network
reception meaning it's useless as a phone. Read some emails and then
the battery is so drained the smart phone being smart turns itself
off.

So you get back home and after messing about trying to work out how to
not let pulseaudio screw over your M-Audio Delta 66 sound card and
then finally realizing you don't even need it for that new piece of
software which you installed it for in the first place, get rid of it,
log back into your shell via a real proper linux running proper real
not smart desktop pc this time.

Some searching the internets yields little about sizeof() returning
zero other than what you vaguely new, but nothing relevant to this
context. cat /proc/cpuinfo says Dual-Core AMD Opteron(tm) Processor
2212 HE. gcc.gnu.org says -march=k8. ./configure says sizeof(int) is
cached. rm config.cache. CONFIG.H stills says SIZEOF_INT 0. A bodge
job is in order.

test:
#include <stdio.h>
int main(int argc, char* argv[])
{
        printf("sizeof(int):%d\n",sizeof(int));
        printf("sizeof(long):%d\n",sizeof(long));
        return 0;
}
----
sizeof(int):4
sizeof(long):8
----
nano config.h to reflect.
make
works!

./jpeginfo: error while loading shared libraries: libjpeg.so.8: cannot
open shared object file: No such file or directory

searching the internets of course brings false hope until:
http://stackoverflow.com/questions/4033981/how-to-link-shared-libraries-in-local-directory-osx-vs-linux

tells to export LD_LIBRARY_PATH=${HOME}/usr/lib

make install

./jpeginfo
jpeginfo: file arguments missing
Try 'jpeginfo --help' for more information.

Hurrah I thankyou thankyou, bows, bows, bows.

for completeness tail -2 ~/.bashrc

export LD_LIBRARY_PATH=${HOME}/usr/lib
export PATH=${HOME}/usr/bin:${PATH}



More information about the NetBehaviour mailing list