grpc.io
grpc.io copied to clipboard
c++ quickstart: zlib installation ignores CMAKE_INSTALL_PREFIX?
When installing gRPC with "install from submodules" option here: https://github.com/grpc/grpc.io/blame/810f55bec86dcf8c726e890ecbc315368ca18575/content/docs/languages/cpp/quickstart.md#L104
What I've done is this:
cmake -DCMAKE_INSTALL_PREFIX=$HOME/grpc_install -DgRPC_INSTALL=ON ../..
make -j
make install
Build worked normally, but it seems that when installing dependencies from submodules, zlib is ignoring the CMAKE_INSTALL_PREFIX (it tries to install under /usr/local/lib) - at least on linux.
CMake Error at third_party/zlib/cmake_install.cmake:60 (file):
file INSTALL cannot copy file
"/usr/local/google/home/jtattermusch/github/grpc/cmake/build/third_party/zlib/libz.so.1.2.11"
to "/usr/local/lib/libz.so.1.2.11": Permission denied.
Call Stack (most recent call first):
cmake_install.cmake:2356 (include)
So it looks like the quickstart instructions don't always work?
because most linux distros have zlib-dev package available, I was able to fix the problem by setting -DgRPC_ZLIB_PROVIDER=package (= don't install zlib from submodule, but look for the system-installed zlib).
@chalin I'm surprised the instructions worked for you. How did you test?
How did you test?
I tested under what was initially a fresh install of Ubuntu 16 and 18. I tested quite a few configurations so something might have fallen between the cracks. I can try again. Which flavour of Linux are you using?
Hmm, is this the same problem: CMAKE_INSTALL_PREFIX is partially ignored and leads to installation error #11951?
zlib is ignoring the CMAKE_INSTALL_PREFIX
If zlib is ignoring the prefix, then the problem here is zlib. My suggestion would be to add a note warning users that they can face a problem, and suggest using -DgRPC_ZLIB_PROVIDER=package
in that case.
Did you have something else in mind?
@chalin I have debian 10 (a custom version of it) and cmake 3.16 Can you please try the current instructions once again and check if it works for you or if it's broken.
In terms of fixing, I agree this would be a bug in zlib and using -DgRPC_ZLIB_PROVIDER=package
seems like a reasonable workaround - but I'd like to check first if you're seeing the same behavior.
... try the current instructions once again
Yes. Would you like me to retry under Ubuntu or Debian?
Hello there,
Not sure if this has been fixed, but i get the same behaviour while installing from source. I followed the instructions here:
$ git clone --recurse-submodules -b v1.32.0 https://github.com/grpc/grpc
$ cd grpc
Then:
$ mkdir -p cmake/build
$ pushd cmake/build
$ cmake -DgRPC_INSTALL=ON \
-DgRPC_BUILD_TESTS=OFF \
-DCMAKE_INSTALL_PREFIX=$MY_INSTALL_DIR \
../..
$ make -j
$ make install
$ popd
And i get this:
-- Installing: /usr/local/lib/libz.so.1.2.11
CMake Error at third_party/zlib/cmake_install.cmake:60 (file):
file INSTALL cannot copy file
"/home/hidden/grpc/cmake/build/third_party/zlib/libz.so.1.2.11"
to "/usr/local/lib/libz.so.1.2.11": Success.
Call Stack (most recent call first):
cmake_install.cmake:2293 (include)
It is trying to install on /usr/local/lib instead of the folder i provided as CMAKE_INSTALL_PREFIX
I'm running on CentOS7.6 with CMake 3.17
FYI,
If i do a sudo make install
the file are copied to /usr/local/lib, afterwards if i redo a make install
(without sudo) then now it is installed in CMAKE_INSTALL_PREFIX
faced the same problem in CentOS 7.
Solved by run sudo make install
, and libz
was installed in /usr/local/lib
as a result.
Run in the issue because of -DCMAKE_INSTALL_PREFIX=
and resolved it as suggested by -DgRPC_ZLIB_PROVIDER=package
For -DgRPC_ZLIB_PROVIDER=package
to work also needed to first sudo apt install zlib1g-dev
on Ubuntu.