Why `make install` is deleting library files *.so generated by `make`? - makefile

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.

Related

Getting cmake to work under Cygwin on Windows 7

I installed the latest Cygwin on my Windows 7 machine: version 2.893 (64-bits). I made sure I included cmake, i.e. I was able to add several packages by running the Cygwin net release setup program again, after doing the first installation. I then tried to use cmake and made sure I invoked it from the bin directory:
user008#L0147816 /bin
$ ./cmake
CMake Error: Could not find CMAKE_ROOT !!!
CMake has most likely not been installed correctly.
Modules directory not found in
//share/cmake-3.6.2
Usage
cmake [options] <path-to-source>
cmake [options] <path-to-existing-build>
Specify a source directory to (re-)generate a build system for it in the
current working directory. Specify an existing build directory to
re-generate its build system.
Run 'cmake --help' for more information.
I don't know where the build directory could be. I'm relatively new to Cygwin. I hope somebody has found a solution for getting cmake installed and working properly under Cygwin.
This looks cmake 101.
Assuming you want to just build a software download from somewhere
eg gl2ps:
# choosing a test area
$ cd /tmp
# downloading source
$ wget http://geuz.org/gl2ps/src/gl2ps-1.4.0.tgz
# expanding source code
$ tar -xf gl2ps-1.4.0.tgz
$ ls gl2ps-1.4.0-source/
CMakeLists.txt COPYING.LGPL gl2ps.h gl2ps.tex gl2psTestSimple.c
COPYING.GL2PS gl2ps.c gl2ps.pdf gl2psTest.c README.txt
# preparing a build area
$ mkdir build
$ cd build
# invoking cmake and pointing to the source directory
$ cmake ../gl2ps-1.4.0-source/
-- The C compiler identification is GNU 7.3.0
[cut ...]
-- Configuring done
-- Generating done
-- Build files have been written to: /tmp/build
# running the build
$ make
Scanning dependencies of target shared
[ 11%] Building C object CMakeFiles/shared.dir/gl2ps.o
...
[ 88%] Building C object CMakeFiles/gl2psTestSimple.dir/gl2psTestSimple.o
[100%] Linking C executable gl2psTestSimple.exe
[100%] Built target gl2psTestSimple
Instead for learning how to build with cmake, go to
https://cmake.org/cmake-tutorial/
Here a solution I just found.
Let's name 3 directories:
{cygwin64-path}/bin/: cmake.exe is here.
{cygwin64-path}/usr/share/: cmake module directory (such as cmake-3.20.0) is here.
{cygwin64-path}/share/: cmake.exe trying to find cmake-module-directory here, but it doesn't exist.
It's wired because cygwin install cmake-module-directory in {cygwin64-path}/usr/share/, but cmake.exe looks for the directory in {cygwin64-path}/share/.
So solution is simple. Each one below works.
METHOD 1: Create the directory {cygwin64-path}/share/ and copy all relevant directories and files from {cygwin64-path}/usr/share/ to the new directory.
METHOD 2: Create a Symbolic links {cygwin64-path}/share/ to {cygwin64-path}/usr/share/.
In windows 10 Administrator cmd.exe: mklink /J share usr\share and all works.
Or use WSL or Cygwin64 Terminal: ln -s usr/share share

Yocto: Adding glibc libraries to the rootfs

I am building binaries for our custom board(iMX7) using Yocto-morty. I need some libraries such as UTF-32.so, UTF-16.so, UTF-7.so from glibc package for bluetooth file tranfer. But these libraries are not available in the rootfs, only files available under /usr/lib/gconv are gconv-modules and ISO8859-1.so. So I am trying to add these libraries by adding new bbappend file glibc_2.24.bbappend with the following content
FILES_${PN} += "${libdir}/gconv/*"
do_install_locale_append() {
cp -r ${dest}${libdir}/gconv ${D}${libdir}/
}
But it results in the following error:
ERROR: glibc-2.24-r0 do_populate_sysroot: The recipe glibc is trying to install files into a shared area when those files already exist. Those files and their manifest location are:
build_dir/tmp/sysroots/esomimx7d/usr/lib/gconv/ISO-2022-CN.so Matched in b'manifest-esomimx7d-glibc-locale.populate_sysroot'
build_dir/tmp/sysroots/esomimx7d/usr/lib/gconv/ARMSCII-8.so Matched in b'manifest-esomimx7d-glibc-locale.populate_sysroot'
......
Then I tried to remove the glibc-locale from the image but due to some dependency issues I could not do that.
Could anyone help me to add the above mentioned libraries to the rootfs?
The error is telling you the answer to your problem. Those files are part of the glibc-locale recipe, so you just need to install the right packages into the rootfs.
$ oe-pkgdata-util find-path \*/UTF-7.so
glibc-gconv-utf-7: /usr/lib/gconv/UTF-7.so
So you need to add glibc-gconv-utf-7 (or -utf-32, etc) to your image.
You can remove thm and compile again it will work.
rm build_dir/tmp/sysroots/esomimx7d/usr/lib/gconv/ISO-2022-CN.so
rm build_dir/tmp/sysroots/esomimx7d/usr/lib/gconv/ARMSCII-8.so
This is for work around only we need for perminant sol.
These files are belongs to glibc-locale so you need to install the required packages.
$ oe-pkgdata-util find-path */UTF-7.so
glibc-gconv-utf-7:> /usr/lib/gconv/UTF-7.so
Add the glibc-gconv-utf-7 (or -utf-32, etc) to recipe image(e.g core-image-minimal).

Trouble installing OpenCV with Cmake

I am trying to install the openCV library for Python however I am new to CMake and have run into some trouble after having cloned the repository in ~/opencv.
I've made a build directory in it with the mkdir command however once inside it when trying to set CMake options in it.
cmake -D CMAKE_BUILD_TYPE=RELEASE -D CMAKE_INSTALL_PREFIX=/usr/local
I get prompted with the following error:
CMake Error: The source directory "/Users/eDen/opencv/build/CMAKE_INSTALL_PREFIX=/usr/local" does not exist.
It seems you aren't making the right directory, some Mac OS X installations doesn't include /usr/local/. You can make the directory using, if it's not already created, with:
sudo mkdir /usr/local/
But you say you want to use OpenCV with Python. I recommend you to obtain an already compiled copy unless you need some advanced features not available in the compiled version, like Qt integration or CUDA programming. But these features are included in the arguments of the cmake command.
Instructions on how to obtain OpenCV from Homebrew repository, this page explains the process. Basically, you install Homebrew, then Python, configure it and install some dependencies.
As Tsyvarev mentioned in the comments, you need to specify the path to source directory (i.e. where the main CMakeLists.txt file exists) at the end of your command. So, supposing you are now in the build directory, the final cmake command would be as follows:
cmake -D CMAKE_BUILD_TYPE=RELEASE -D CMAKE_INSTALL_PREFIX=/usr/local ..
I have the last argument as .. but still get the error.
In my case, there is a bad whitespace in the above arguments. So the last .. is ignored.

Need help to build Boost from source for MinGW

I was trying to build Boost library from source for MinGW. The Boost website says no guarantee but there seem to be people done it successfully. However I couldn't find much instructions on the web.
I updated the title to better reflect my problem right now.
======================== Original post ==============================
I downloaded Boost 1.53.0, unzipped it and cd to the folder in MinGW shell. It failed at the very first step I tried:
$ ./bootstrap.sh mingw
Building Boost.Build engine with toolset gcc...
Failed to build Boost.Build build engine
Consult 'bootstrap.log' for more details
Inside the bootstrap.log the errors are:
builtins.c:33:23: fatal error: sys/wait.h: No such file or directory
compilation terminated.
execunix.c:17:26: fatal error: sys/resource.h: No such file or directory
compilation terminated.
fileunix.c:98:17: fatal error: ar.h: No such file or directory
compilation terminated.
Please help! Thanks!
================== End of original and beginning of update =====================
Update: I found this detailed instruction on line:
http://vijay.axham.com/blog/478/building-boost-binaries-on-mingw
I followed it along and now got stuck in the final build step that is supposed to take a long time but I got an error instead:
$ b2 --build-dir=$BOOST_BUILD_DIR --prefix=$BOOST_INSTALL_DIR toolset=gcc variant=release link=static threading=multi runtime-link=static install 2>&1 | tee $BOOST_BUILD_DIR/build.log
error: Unable to find file or target named
error: 'boost/tr1/tr1/bcc32'
error: referred from project at
error: '.'
but the directory is there (it should be since it's just extracted from the zip file)
$ ls boost/tr1/tr1/bcc32/
array.h random.h regex.h tuple.h type_tra.h unordere.h
Getting closer but still need help! Thanks!
OK I got it working. The trick was to download the tar.bz2 file, not the zip file from sourceforge (specifically http://sourceforge.net/projects/boost/files/boost/1.53.0/). Even though both the zip and the tar.bz2 files are listed under the same file folder for the same version of Boost, the contents are different. There are some missing folders in the zip file, and the line ending conventions of the compressed files are different. At any rate after I downloaded and extracted the tar.bz2 file. I followed the instructions given here:
http://vijay.tech/articles/wiki/Programming/Cpp/Boost/BuildingBoostOnMinGw
and successfully built the Boost library from source using MinGW shell (mintty to be exact). There were some failures but probably not important: has_icu_test, has_iconv, has_icu_obj, has_icu64_obj, .masm. At the end it says
...failed updating 2 targets...
...skipped 3 targets...
...updated 10623 targets...
Hope this will help others in the future.
Do not use bash. Build it using cmd.exe.
bootstrap.bat gcc
Compiler executable should be on PATH.
Do not use bash. Build it using cmd.exe as described below:
Install MinGw on your system. I recommend using the same bit system as your processor is. Then set the path in System Environment to the bin folder which contains g++, ... (Compiler executable should be on PATH.) files. Now you are ready to go.
For obvious reasons, start a fresh terminal (cmd.exe), don't use the already open terminals that doesn't know your new setting.
Download boost, the latest stable release, unzip it and in the command window follow the path too the main directory of the extracted boost.
Run this command: bootstrap mingw
Run this command afterwards, which will install in the folder you select as your destination.
b2 install --prefix=c:\boost\custominstallationfolder\gcc toolset=gcc
Like said above, but more specifically for me compiling boost-1.54 with gcc-mingw-4.8.1
Using a Windows shell (cmd.exe) navigate to root of boost directory directory then
bootstrap.bat gcc
b2.exe toolset=gcc

macos - how to tell cabal/ghc to look in /opt for libraries/include files?

I've got the pcre library installed via ports in /opt.
I'm trying to install pcre-light, but cabal install pcre-light reports:
Resolving dependencies...
Configuring pcre-light-0.4...
Preprocessing library pcre-light-0.4...
Base.hsc:103:18: error: pcre.h: No such file or directory
...
pcre.h is located in /opt/local/include
Update: I had trouble linking with the pcre library provided by macports, so I switched over to using home brew.
http://www.haskell.org/ghc/docs/7.0.2/html/Cabal/builders.html
--extra-include-dirs[=dir]
An extra directory to search for C header files. You can use this flag multiple times to get a list of directories.
You might need to use this flag if you have standard system header files in a non-standard location that is not mentioned in the package's .cabal file. Using this option has the same affect as appending the directory dir to the include-dirs field in each library and executable in the package's .cabal file. The advantage of course is that you do not have to modify the package at all. These extra directories will be used while building the package and for libraries it is also saved in the package registration information and used when compiling modules that use the library.

Resources