I am compiling C++ Poco libraries. I do
cmake -DCMAKE_INSTALL_PREFIX=./ -DCMAKE_BUILD_TYPE=Debug ../
make
make install
At make install
I get an error
"path/poco/instDir/lib/libPocoEncodingsd.so.60".
Call Stack (most recent call first):
cmake_install.cmake:50 (include)
Makefile:85: recipe for target 'install' failed
make: *** [install] Error
Basically the file libPocoEncodingsd.so.60
is created with make
but then make install
deletes it.
Why is that?
If I do not run make install
the folder inside the installation path is not created and all the *.h
files are not copied there.
This happens because:
-DCMAKE_INSTALL_PREFIX=./
means that you are installing over the top of the build directory itself, with the result that for each filename in the cmake command:
file(INSTALL DESTINATION "${CMAKE_INSTALL_PREFIX}/lib" TYPE SHARED_LIBRARY FILES
"path/poco/instDir/lib/libPocoEncodingsd.so.60"
"path/poco/instDir/lib/libPocoEncodingsd.so"
)
the source and destination files are the same. Cmake preemptively deletes the destination file to replace it with the source file. Which means it has deleted the source file. Hence your failure.
This behaviour may be a bug in cmake. On the face of it, if it checks and finds that the destination file exists and has the same timestamp as the source file, it should consider the destination file up to date and not attempt to replace it. But I haven't delved into that. Installing on top of your build directory is reasonably classified under Don't do that.
Conventionally on Unix-like OSes, locally built packages shall be installed to
/usr/local
. That's what /usr/local
is for. Cmake, like other source package
deployment tools, respects this convention by default. So if you simply run:
cmake -DCMAKE_BUILD_TYPE=Debug ../
make
sudo make install # Or however you run `make install` as root.
then the poco
libraries will be installed in /usr/local/lib
and the headers
in /usr/local/include/Poco
. /usr/local/lib
is a default library search path for the
linker and /usr/local/include
is a default header search path for the compiler.
If for some reason you don't want to install to the default prefix, then choose some:
-DCMAKE_INSTALL_PREFIX=/not/in/the/build/dir
and you will avoid this problem.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With