Can't add external project using ExternalProject_Add in CMake - build

The problem I have is very strange: I try to add an external project (the metis library) to my CMake project:
set(METIS_VERSION "5.1.0")
set(METIS_ARCHIVE "${PROJECT_SOURCE_DIR}/third-party/metis-${METIS_VERSION}.tar.gz")
if(NOT EXISTS ${METIS_ARCHIVE})
set(METIS_ARCHIVE "http://glaros.dtc.umn.edu/gkhome/fetch/sw/metis/metis-${METIS_VERSION}.tar.gz")
endif()
set(METIS_DIR ${PROJECT_BINARY_DIR}/third-party/metis)
set(METIS_ROOT ${METIS_DIR}/src/Metis)
ExternalProject_Add(Metis
PREFIX ${METIS_DIR}
DOWNLOAD_DIR "${PROJECT_SOURCE_DIR}/third-party"
URL ${METIS_ARCHIVE}
URL_HASH "MD5=5465e67079419a69e0116de24fce58fe"
PATCH_COMMAND patch ${METIS_ROOT}/CMakeLists.txt < ${PROJECT_SOURCE_DIR}/cmake/Metis-CMakeLists.txt.patch
SOURCE_DIR ${METIS_ROOT}
CONFIGURE_COMMAND $(MAKE) config shared=1 prefix=${METIS_ROOT} cc=${CMAKE_C_COMPILER}
BINARY_DIR ${METIS_ROOT}
BUILD_COMMAND $(MAKE)
)
The configure goes fine, but when I try to make, I get the following error message:
[100%] Built target metis
make[5]: *** No rule to make target `s'. Stop.
make[4]: *** [all] Error 2
make[3]: *** [third-party/metis/src/Metis-stamp/Metis-build] Error 2
make[2]: *** [CMakeFiles/Metis.dir/all] Error 2
make[1]: *** [all] Error 2
make: *** [all] Error 2
Now the interesting part, if I invoke make in verbose mode (VERBOSE=1 make), the code runs fine and I have no errors. Also, I checked running make -C build/Darwin-x86_64/third-party/metis/src/Metis/ and this also works fine
Does someone know what's the issue here?
aa

I checked running make -C build/Darwin-x86_64/third-party/metis/src/Metis/ and this also works fine
99,9% blame environment (:
You can test it by using printenv command:
BUILD_COMMAND printenv && make
copy the result of printenv and compare it with the "clean" one. You must see some diffs, for me it's:
MFLAGS
MAKEFLAGS
MAKELEVEL
I don't know what is the reason of the issue exactly but when I unset this variables everything works fine (note that you need to update the install command too):
BUILD_COMMAND unset MFLAGS && unset MAKEFLAGS && unset MAKELEVEL && make
INSTALL_COMMAND unset MFLAGS && unset MAKEFLAGS && unset MAKELEVEL && make install

Related

Build Bitcoin with cmake

I tried to compile bitcoin with cmake and I get the following error.
system info:
4.4.0-116-generic
cmake version 3.5.1
gcc version 5.4.0 20160609 (Ubuntu 5.4.0-6ubuntu1~16.04.10)
CMakeLists.txt (Demo)
cmake_minimum_required(VERSION 2.8.12.2)
project(Bitcoin)
#set(CMAKE_CXX_STANDARD 11)
add_definitions(-std=c++11)
......
get_property(dirs DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} PROPERTY INCLUDE_DIRECTORIES)
foreach(dir ${dirs})
message(STATUS "dir='${dir}'")
endforeach()
aux_source_directory(./src/ DIR_SRCS)
add_executable(bitcoin ${DIR_SRCS})
cmake .
-- Configuring done
-- Generating done
-- Build files have been written to: /home/fyn/bitcoin
make
In file included from /usr/include/stdlib.h:42:0,
from /usr/include/c++/5/cstdlib:72,
from /usr/include/c++/5/ext/string_conversions.h:41,
from /usr/include/c++/5/bits/basic_string.h:5249,
from /usr/include/c++/5/string:52,
from /home/youwei/bitcoin/src/fs.h:9,
from /home/youwei/bitcoin/src/fs.cpp:1:
/usr/include/x86_64-linux-gnu/bits/waitstatus.h:79:27: error: redeclaration of ‘unsigned int wait::<anonymous struct>::__w_retcode’
unsigned int __w_retcode:8;
^
/usr/include/x86_64-linux-gnu/bits/waitstatus.h:74:27: note: previous declaration ‘unsigned int wait::<anonymous struct>::__w_retcode’
unsigned int __w_retcode:8; /* Return code if exited normally. */
^
/usr/include/x86_64-linux-gnu/bits/waitstatus.h:80:28: error: redeclaration of ‘unsigned int wait::<anonymous struct>::__w_coredump’
unsigned int __w_coredump:1;
CMakeFiles/bitcoin.dir/build.make:86: recipe for target 'CMakeFiles/bitcoin.dir/src/fs.cpp.o' failed
make[2]: *** [CMakeFiles/bitcoin.dir/src/fs.cpp.o] Error 1
CMakeFiles/Makefile2:67: recipe for target 'CMakeFiles/bitcoin.dir/all' failed
make[1]: *** [CMakeFiles/bitcoin.dir/all] Error 2
Makefile:83: recipe for target 'all' failed
make: *** [all] Error 2
You are clearly missing some libaries. Run
./autogen.sh
./configure --with-gui=no --disable-wallet
and check the logs (which will tell you which libaries are missing)
Edit: I suggest to remove --with-gui=no --disable-wallet if you want to know full compability.
I also ran into problems compiling bitcoin, as it has a lot of dependencies but it turns out it has a depends system built in to tackle that issue. It's best to utilize it when compiling. So, from scratch:
clone the bitcoin repo and build the depends system:
git clone https://github.com/bitcoin/bitcoin.git
cd bitcoin/depends
make
Once this completes successfully, you'll see a new folder in the depends directory with the name corresponding to your environment, e.g. x86_64-pc-linux-gnu. Set the path to this folder when running ./configure from the repository's root folder using the --prefix flag and run make:
cd ..
./autogen.sh
./configure --prefix=`pwd`/depends/x86_64-pc-linux-gnu
make

Install GCC: fatal error: gnu/stubs-32.h: No such file or directory

I'm using a server with Centos 6.6. I don't have root access and I want to install the gcc-4.8.1 to my own directory. I found a solution and I run the following commands:
wget http://www.netgull.com/gcc/releases/gcc-4.8.1/gcc-4.8.1.tar.gz
tar zxvf gcc-4.8.1.tar.gz
cd gcc-4.8.1
./contrib/download_prerequisites
cd ..
mkdir objdir
cd objdir
$PWD/../gcc-4.8.1/configure --prefix=$HOME/gcc-4.8.1 --enable-languages=c,c++,fortran,go
make
I got errors when running the make command. It reports the following information:
configure: error: `CC' has changed since the previous run:
configure: former value: `/home/mypath/software/try_gcc2/objdir/./gcc/xgcc -B/home/mypath/software/try_gcc2/objdir/./gcc/ -B/home/mypath/software/try_gcc2/installed/x86_64-unknown-linux-gnu/bin/ -B/home/mypath/software/try_gcc2/installed/x86_64-unknown-linux-gnu/lib/ -isystem /home/mypath/software/try_gcc2/installed/x86_64-unknown-linux-gnu/include -isystem /home/mypath/software/try_gcc2/installed/x86_64-unknown-linux-gnu/sys-include '
configure: current value: `/home/mypath/software/try_gcc2/objdir/./gcc/xgcc -B/home/mypath/software/try_gcc2/objdir/./gcc/ -B/home/mypath/gcc-4.8.1/x86_64-unknown-linux-gnu/bin/ -B/home/mypath/gcc-4.8.1/x86_64-unknown-linux-gnu/lib/ -isystem /home/mypath/gcc-4.8.1/x86_64-unknown-linux-gnu/include -isystem /home/mypath/gcc-4.8.1/x86_64-unknown-linux-gnu/sys-include '
configure: error: in `/home/mypath/software/try_gcc2/objdir/x86_64-unknown-linux-gnu/libgcc':
configure: error: changes in the environment can compromise the build
configure: error: run `make distclean' and/or `rm ./config.cache' and start over
make[2]: *** [configure-stage1-target-libgcc] Error 1
make[2]: Leaving directory `/home/mypath/software/try_gcc2/objdir'
make[1]: *** [stage1-bubble] Error 2
make[1]: Leaving directory `/home/mypath/software/try_gcc2/objdir'
make: *** [all] Error 2
I cannot figure what's wrong with my command. Thank you all for helping me!!!
I think I have found the solution. When I'm trying to build gcc-5.2.0, it reports that my server does not have 32-bit libraries. It also informs that if I still want to install anyway, I can add --disable-multilib when building. I tried and now the build is running normally.

"No rule to make target" compiling c++ module for Apache Ignite

When compiling the c++ module from sources I am getting the following error, which seems to arise because the file "ignite/impl/interop/interop_target.h" is missing. Any suggestions where I should go from here?
Making all in include
make[3]: Entering directory `/work/apache-ignite-1.7.0-src/modules/platforms/cpp/core/include'
make[3]: Leaving directory `/work/apache-ignite-1.7.0-src/modules/platforms/cpp/core/include'
make[3]: *** No rule to make target `ignite/impl/interop/interop_target.h', needed by `all-am'. Stop.
make[2]: *** [all-recursive] Error 1
make[2]: Leaving directory `/work/apache-ignite-1.7.0-src/modules/platforms/cpp/core'
make[1]: *** [all-recursive] Error 1
make[1]: Leaving directory `/work/apache-ignite-1.7.0-src/modules/platforms/cpp'
make: *** [all] Error 2
The command '/bin/sh -c cd /work/apache-ignite-1.7.0-src/modules/platforms/cpp && libtoolize && aclocal && autoheader && automake --add-missing && autoreconf && ./configure && make -j4' returned a non-zero code: 2
Where the build process I am following, leading up to the error, is
cd /work
curl -L -O https://archive.apache.org/dist/ignite/1.7.0/apache-ignite-1.7.0-src.zip
unzip -q apache-ignite-1.7.0-src.zip
cd apache-ignite-1.7.0-src
mvn clean package -DskipTests
cd modules/platforms/cpp
libtoolize && aclocal && autoheader && automake --add-missing && autoreconf
./configure
make -j4
Incidentally I am getting the same error if I repeat the build process on apache-ignite-1.8.0-src.zip.
This is a known issue with the sources releases. As a solution, you can use sources from project repository.

Can't compile Rust

I'm on Debian and following the compile instructions from the Rust wiki: https://github.com/mozilla/rust/wiki/Doc-getting-started
I tried a couple of times but it always ends up with the following error:
llvm[3]: Compiling opt.cpp for Release+Asserts build
make[3]: *** No rule to make target `/home/user/rust/llvm/x86_64-unknown-linux-
gnu/tools/lib/libLLVMipo.a', needed by `/home/user/rust/llvm/x86_64-unknown-
linux-gnu/Release+Asserts/bin/opt'. Stop.
make[3]: Leaving directory `/home/user/rust/llvm/x86_64-unknown-linux-gnu/
tools/opt'
make[2]: *** [opt/.makeall] Error 2
make[2]: Leaving directory `/home/user/rust/llvm/x86_64-unknown-linux-gnu/tools'
make[1]: *** [all] Error 1
make[1]: Leaving directory `/home/user/rust/llvm/x86_64-unknown-linux-gnu'
make: *** [/home/user/rust/llvm/x86_64-unknown-linux-gnu/Release+Asserts/
bin/llvm-config] Error 2
Edit:
The problem only occurs whithin a debootstrap/chroot environment, not within a full Debian Installation.
If you're referring to these instructions:
git clone git://github.com/mozilla/rust.git
cd rust
mkdir build
cd build
../configure
make check
...I can see at least one thing wrong with them. Try this instead:
git clone git://github.com/mozilla/rust.git
cd rust
git submodule update --init
./configure
make
sudo make install
The git submodule update --init is necessary to initialize Rust's submodules, which include LLVM and libuv.
git submodule update shouldn't be needed, as Rust's configure script tries to handle that itself, but if you run git submodule status and see lines about changes to src/libuv or src/llvm then it could be a problem.
I haven't seen that error before and can't tell what's wrong from that snippet. Possibly run make clean-all then gist the full output of ./configure && make, as well as the contents of config.mk. Also, you will probably get more attention with this question on the rust bug tracker: http://github.com/mozilla/rust/issues

gcc 4.5 installation problem under ubuntu

I tried to install gcc 4.5 on ubuntu 10.04 but failed.
Here is a compile error that I don't know how to solve. Is there anyone successfully install the latest gcc on ubuntu?
Following is my steps and the error message, I'd like to know where is the problem....
Step1: download these files:
gcc-core-4.5.0.tar.gz
gcc-g++-4.5.0.tar.gz
gmp-4.3.2.tar.bz2
mpc-0.8.1.tar.gz
mpfr-2.4.2.tar.gz
Step2: Unzip above files
Step3: move gmp, mpc, mpfr to the gcc-4.5.0/ directory.
mv gmp-4.3.2 gcc-4.5.0/gmp
mv mpc-0.8.1 gcc-4.5.0/mpc
mv mpfr-2.4.2 gcc-4.5.0/mpfr
Step4: go to gcc-4.5.0 directory and do configuration:
sudo ./configure
Step5: compile and install
sudo make
sudo make install
The first 4 steps is OK, I can configure it successfully. However, when I try to compile it, following error message comes out, I cannot figure out what the problem is. Should I change the name from "gcc 4.5" to "gcc"?? It's a little strange that we need to do this by ourself. Is there anything I missed during the installation?
xxx#xxx-laptop:/media/Data/Tool/linux/gcc 4.5/gcc-4.5.0$ sudo make
[sudo] password for xxx:
[ -f stage_final ] || echo stage3 > stage_final
/bin/bash: line 2: test: /media/Data/Tool/linux/gcc: binary operator expected
/bin/bash: /media/Data/Tool/linux/gcc: No such file or directory
make[1]: Entering directory `/media/Data/Tool/linux/gcc 4.5/gcc-4.5.0'
make[2]: Entering directory `/media/Data/Tool/linux/gcc 4.5/gcc-4.5.0'
make[3]: Entering directory `/media/Data/Tool/linux/gcc 4.5/gcc-4.5.0'
rm -f stage_current
make[3]: Leaving directory `/media/Data/Tool/linux/gcc 4.5/gcc-4.5.0'
make[2]: Leaving directory `/media/Data/Tool/linux/gcc 4.5/gcc-4.5.0'
make[2]: Entering directory `/media/Data/Tool/linux/gcc 4.5/gcc-4.5.0'
Configuring stage 1 in host-x86_64-unknown-linux-gnu/intl
/bin/bash: /media/Data/Tool/linux/gcc: No such file or directory
make[2]: *** [configure-stage1-intl] Error 127
make[2]: Leaving directory `/media/Data/Tool/linux/gcc 4.5/gcc-4.5.0'
make[1]: *** [stage1-bubble] Error 2
make[1]: Leaving directory `/media/Data/Tool/linux/gcc 4.5/gcc-4.5.0'
make: *** [all] Error 2
It might not be a good idea to have a space in your path - it's kind of rare and can easily mess up shell scripts that aren't specially designed to deal with it (which is a bad combination!)
Another potential problem is that you're running configure inside the gcc source directory - this isn't recommended (and didn't work at all for me on at least one version of gcc 4). Instead make an empty build directory, parallel to the source directory, so you have something like:
gcc 4.5 <- but might want to avoid the space
gcc-4.5.0
...
build
Then cd into build and run
../gcc-4.5.0/configure
You may also need to start from a freshly unzipped source directory, as the previous failed build may have broken it.