zlib.h in custom path

I am trying to configure gpac. I get the error as follows.

[root@ffmpeg gpac]# ./configure
error: zlib not found on system or in local libs

I have installed zlib on custom path /usr/local/myapps. I know the above error occurs when devel package or .h file is not present. Its present on the server.

[root@ffmpeg gpac]# ll /usr/local/myapps/include/zlib.h
-rw-r--r-- 1 root root 79564 Jul  4 02:12 /usr/local/myapps/include/zlib.h
[/code[
I have given environment variables as follows.
LIBS=-L/usr/local/myapps/lib
PKG_CONFIG_PATH=/usr/local/myapps/lib/pkgconfig
LDFLAGS=-L/usr/local/myapps/lib
CPPFLAGS=-I/usr/local/myapps/include
PATH=/usr/local/sbin:/bin:/sbin:/usr/bin:/usr/sbin::/root/bin:/usr/local/myapps/bin

Again .pc file also present.

[root@ffmpeg gpac]# ll /usr/local/myapps/lib/pkgconfig/zlib.pc
-rw-r--r-- 1 root root 265 Jul  4 02:12 /usr/local/myapps/lib/pkgconfig/zlib.pc

How to make the gpac configure script recognize the zlib.h file from the path /usr/local/myapps/include ? I made a symlink to /usr/include/zlib.h and it did not work. Installing zlib-devel via yum solves the problem. But yum installs a differerent zlib version. I need to use custom zlib.

where did you define variable of CPPFLAGS ?(In parent shell or in your configure script)

Did in both shell and configure script.

configure script snippet

CPPFLAGS=-I/usr/local/myapps/include
CFLAGS=-I/usr/local/myapps/include

cat > $TMPC << EOF
#include <zlib.h>
int main( void ) { if (zlibVersion() != ZLIB_VERSION) { puts("zlib version differs !!!"); return 1; } return 0; }
EOF
has_zlib="no"
if $cc -o $TMPO $TMPC -lz 2> /dev/null  ; then
has_zlib="system"
elif $cc -o $TMPO $TMPC -I$local_inc/zlib -L$local_lib -lz 2> /dev/null  ; then
has_zlib="local"
else
  echo "error: zlib not found on system or in local libs"
  exit 1
fi

error:

[root@ffmpeg gpac]# ./configure
error: zlib not found on system or in local libs

firstly , remove the stderr sending null and lets see what happen :wink:
probably , error occurs due to another things,maybe variables (be sure all variables is defined like TMPC,TMPO..)

and you can try with this (more specific)

.......
cat > $TMPC << EOF
#include<stdio.h>
#include <zlib.h>
#include <string.h>
int main( void ) {
static const char* curV = ZLIB_VERSION;
if (zlibVersion()[0] != curV[0]) {
printf("zlib versions has major different using..%s and,currently in system..%s\n" ,zlibVersion(),ZLIB_VERSION);
return 1;}
else if ( strcmp (zlibVersion(),ZLIB_VERSION) != 0 )  {
printf( "you are using %s, cur version %s.\n",zlibVersion(),ZLIB_VERSION);
}
return 0;
}
EOF
....
...

regards
ygemici

I removed the stderr and got the following error. I have echoed variables. Let me know if any other variable I should echo. Its not checking the path /usr/local/myapps/include/ where zlib.h is present.

[root@ffmpeg gpac]# ll /usr/local/myapps/include/zlib.h
-rw-r--r-- 1 root root 79564 Jul 4 02:12 /usr/local/myapps/include/zlib.h

[root@ffmpeg gpac]# ./configure
CPPFLAGS  -fno-strict-aliasing
CFLAGS  -fno-strict-aliasing
CFLAGS  -fno-strict-aliasing
cc gcc
TMPC /tmp/gpac-conf-7254-30179-4836.c
TMPO /tmp/gpac-conf-22952-30179-10957.o
local_inc /usr/src/gpac/extra_lib/include
local_lib extra_lib/lib/gcc
CPPFLAGS  -fno-strict-aliasing   --> I set after this to CPPFLAGS to the value below
CPPFLAGS -I/usr/local/myapps/include
/tmp/gpac-conf-7254-30179-4836.c:1:18: error: zlib.h: No such file or directory
/tmp/gpac-conf-7254-30179-4836.c: In function 'main':
/tmp/gpac-conf-7254-30179-4836.c:2: error: 'ZLIB_VERSION' undeclared (first use in this function)
/tmp/gpac-conf-7254-30179-4836.c:2: error: (Each undeclared identifier is reported only once
/tmp/gpac-conf-7254-30179-4836.c:2: error: for each function it appears in.)
error: zlib not found on system or in local libs

Please write output of below commands.

# uname -a
# gcc --version  ## ## if you use gcc

and

  • create tmp.c with below contents
#include <zlib.h>
int main( void ) { if (zlibVersion() != ZLIB_VERSION) { puts("zlib version differs !!!"); return 1; } return 0; }

after than can you write below's output

# gcc -v -o tmp.o tmp.c -lz

and this

# gcc -v -o tmp.o tmp.c -lz -I/usr/local/myapps/include

Thank you. I get this.

[root@ffmpeg gpac]# gcc -o tmp.o tmp.c -lz -I/usr/local/myapps/include
/usr/bin/ld: cannot find -lz
collect2: ld returned 1 exit status

---------- Post updated at 07:53 PM ---------- Previous update was at 07:36 PM ----------

Fixed. I modified the configure script as follows. Thanks a lot !!

cat > $TMPC << EOF
#include <zlib.h>
int main( void ) { if (zlibVersion() != ZLIB_VERSION) { puts("zlib version differs !!!"); return 1; } return 0; }
EOF
has_zlib="no"
if $cc -o $TMPO $TMPC -lz 2> /dev/null ; then
has_zlib="system"
elif $cc -o $TMPO $TMPC -I$local_inc/zlib -L$local_lib -lz -I/usr/local/myapps/include -L/usr/local/myapps/lib 2> /dev/null  ; then
#elif $cc -o $TMPO $TMPC -I$local_inc/zlib -L$local_lib -lz  2> /dev/null  ; then
has_zlib="local"
else
  echo "error: zlib not found on system or in local libs"
  exit 1
fi
** Detected libraries **
zlib: local
OSS Audio: yes
ALSA Audio: no

---------- Post updated at 08:02 PM ---------- Previous update was at 07:53 PM ----------

make returns this error now

positor/texturing.opic compositor/texturing_gl.opic compositor/visual_manager.opic compositor/visual_manager_2d.opic 
compositor/visual_manager_2d_draw.opic compositor/visual_manager_3d.opic compositor/visual_manager_3d_gl.opic
compositor/x3d_geometry.opic laser/lsr_enc.opic laser/lsr_dec.opic laser/lsr_tables.opic -lm
 -L/usr/local/lib -lGL -lglut -L../extra_lib/lib/gcc  -lz -lpthread -ldl
/usr/bin/ld: cannot find -lz
collect2: ld returned 1 exit status
make[1]: *** [libgpac.so] Error 1
make[1]: Leaving directory `/usr/src/gpac/src'
make: *** [lib] Error 2

---------- Post updated at 08:23 PM ---------- Previous update was at 08:02 PM ----------

SOLVED !!
Use make as follows.

make --environment-overrides -I/usr/local/myapps/include
make  --environment-overrides -I/usr/local/myapps/include install

MP4Box works like a charm

[root@ffmpeg gpac]# /usr/local/myapps/bin/MP4Box -version
MP4Box - GPAC version 0.4.5 (build 33)
GPAC Copyright: (c) Jean Le Feuvre 2000-2005
                (c) ENST 2005-200X

congratulations ;):b: