CFD Online Discussion Forums

CFD Online Discussion Forums (http://www.cfd-online.com/Forums/)
-   OpenFOAM Installation (http://www.cfd-online.com/Forums/openfoam-installation/)
-   -   How to solve the zlib.h missing problem without root right (http://www.cfd-online.com/Forums/openfoam-installation/118558-how-solve-zlib-h-missing-problem-without-root-right.html)

seasoul May 29, 2013 22:17

How to solve the zlib.h missing problem without root right
 
Dear All,

I want to build OpenFOAM 2.2.0 on my workstation. But it has to be say that I do not have the root right and the administrator is reluctant to give me the right.

The first error occurred is "fatal error: zlib.h: No such file or directory."

I know that is definitely because the missing of zlib-dev. But since I have no root right, I download zlib source and install it with custom path.

I tried to set the CPPFLAGS as the zlib include directory and even set the LD_LIBRARY_PATH as the libz.so as suggested by this post

Quote:

Originally Posted by gwierink (Post 301615)
Hi Yuri,

Maybe ld can't find zlib or the right zlib. Perhaps it helps to add the location of the right zlib to the LD_LIBRARY_PATH variable. For instance, if zlib lives in /usr/lib/libz.so, then you could add something like below to $HOMA/.bashrc and then source your bashrc:
Code:

LD_LIBRARY_PATH=/usr/lib/libz.so:$LD_LIBRARY_PATH
export LD_LIBRARY_PATH


The compiling still report the error of zlib.

How to solve this zlib.h missing problem without root right?

Best Reagards

wyldckat June 9, 2013 06:54

Greetings seasoul,

Unfortunately that quoted post is incorrect. The variable "LD_LIBRARY_PATH" is only meant for paths to the library files, not for specifying the paths to the files themselves.
So, for the library file itself ("libz.so"), the correct way to do this is:
Code:

export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/path/to/zlib/lib
I haven't managed to test the following with this scenario of a custom zlib, but you can try using the following commands for forcefully adding the zlib "include" folder to the build search path:
Code:

export C_INCLUDE_PATH=/path/to/zlib/include
export CPLUS_INCLUDE_PATH=/path/to/zlib/include

I've had to use this trick in the past for building old GCC compilers in new Ubuntu versions and it worked back then.


If this doesn't work, then you can try another quick hack:
  1. Copy the "zlib.h" file to the folder "$FOAM_SRC/OpenFOAM/lnInclude/".
  2. Edit the file "$WM_THIRD_PARTY_DIR/etc/wmakeFiles/scotch/Makefile.inc.i686_pc_linux2.shlib-OpenFOAM-$WM_ARCH_OPTION" and add the following at the end of the line "CFLAGS":
    Code:

    -I/path/to/zlib/include
If you are unfamiliar with these long variable names, you can simply check what they equate to by running:
Code:

echo "$FOAM_SRC/OpenFOAM/lnInclude/"
echo "$WM_THIRD_PARTY_DIR/etc/wmakeFiles/scotch/Makefile.inc.i686_pc_linux2.shlib-OpenFOAM-$WM_ARCH_OPTION"

Best regards,
Bruno

seasoul June 11, 2013 04:59

This really works.

I tried the first option and it works. So I did not go further.

Thank you, Bruno.:)

Quote:

Originally Posted by wyldckat (Post 432891)
Greetings seasoul,

Unfortunately that quoted post is incorrect. The variable "LD_LIBRARY_PATH" is only meant for paths to the library files, not for specifying the paths to the files themselves.
So, for the library file itself ("libz.so"), the correct way to do this is:
Code:

export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/path/to/zlib/lib
I haven't managed to test the following with this scenario of a custom zlib, but you can try using the following commands for forcefully adding the zlib "include" folder to the build search path:
Code:

export C_INCLUDE_PATH=/path/to/zlib/include
export CPLUS_INCLUDE_PATH=/path/to/zlib/include

I've had to use this trick in the past for building old GCC compilers in new Ubuntu versions and it worked back then.


If this doesn't work, then you can try another quick hack:
  1. Copy the "zlib.h" file to the folder "$FOAM_SRC/OpenFOAM/lnInclude/".
  2. Edit the file "$WM_THIRD_PARTY_DIR/etc/wmakeFiles/scotch/Makefile.inc.i686_pc_linux2.shlib-OpenFOAM-$WM_ARCH_OPTION" and add the following at the end of the line "CFLAGS":
    Code:

    -I/path/to/zlib/include
If you are unfamiliar with these long variable names, you can simply check what they equate to by running:
Code:

echo "$FOAM_SRC/OpenFOAM/lnInclude/"
echo "$WM_THIRD_PARTY_DIR/etc/wmakeFiles/scotch/Makefile.inc.i686_pc_linux2.shlib-OpenFOAM-$WM_ARCH_OPTION"

Best regards,
Bruno



All times are GMT -4. The time now is 07:15.