Build Bitcoin with cmake - c++

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

Related

Build using 0.5 libyaml-cpp-dev fails with boost errors

I installed libyaml-cpp-dev via sudo apt install libyaml-cpp-dev and got yaml-cpp 0.5 version installed on my machine.
dpkg -s libyaml-cpp-dev | grep Version
Version: 0.5.2-4ubuntu1
Using this , I tried to build a testing code, demo.cpp as below:
#include <string>
#include "yaml-cpp/yaml.h"
int main(){
std::string config_file{"/home/freyr/exper/yamp-cpp/rvs.conf"};
YAML::Node config = YAML::LoadFile(config_file);
return 0;
}
with a cmake,
cmake_minimum_required (VERSION 2.8.11)
project (HELLO)
find_package(yaml-cpp REQUIRED)
add_executable (helloDemo demo.cpp)
include_directories(${YAML_CPP_INCLUDE_DIRS})
target_link_libraries(helloDemo ${YAML_CPP_LIBRARIES})
When I tried to build , I get below error:
make: Entering directory '/home/freyr/exper/yamp-cpp/build' make[1]: Entering directory '/home/freyr/exper/yamp-cpp/build' make[2]: Entering directory '/home/freyr/exper/yamp-cpp/build' Scanning dependencies of target helloDemo make[2]: Leaving directory '/home/freyr/exper/yamp-cpp/build' make[2]: Entering directory '/home/freyr/exper/yamp-cpp/build' [ 50%] Building CXX object CMakeFiles/helloDemo.dir/demo.cpp.o In file included from /usr/include/yaml-cpp/node/iterator.h:13:0,
from /usr/include/yaml-cpp/node/impl.h:11,
from /usr/include/yaml-cpp/yaml.h:17,
from /home/freyr/exper/yamp-cpp/demo.cpp:3: /usr/include/yaml-cpp/node/detail/iterator.h: In member function ‘void YAML::detail::iterator_base<V>::increment()’: /usr/include/yaml-cpp/node/detail/iterator.h:48:54: error: ‘next’ is not a member of ‘boost’ void increment() { this->base_reference() = boost::next(this->base()); }
^~~~ /usr/include/yaml-cpp/node/detail/iterator.h:48:54: note: suggested alternatives: In file included from /usr/include/c++/7/bits/stl_algobase.h:66:0,
from /usr/include/c++/7/bits/char_traits.h:39,
from /usr/include/c++/7/ios:40,
from /usr/include/c++/7/ostream:38,
from /usr/include/c++/7/iostream:39,
from /home/freyr/exper/yamp-cpp/demo.cpp:1: /usr/include/c++/7/bits/stl_iterator_base_funcs.h:208:5: note: ‘std::next’
next(_ForwardIterator __x, typename
^~~~ In file included from /usr/local/include/boost/mpl/next.hpp:17:0,
from /usr/local/include/boost/mpl/bind.hpp:25,
from /usr/local/include/boost/mpl/lambda.hpp:18,
from /usr/local/include/boost/mpl/apply.hpp:25,
from /usr/local/include/boost/iterator/iterator_facade.hpp:36,
from /usr/include/yaml-cpp/node/detail/node_iterator.h:12,
from /usr/include/yaml-cpp/node/detail/iterator.h:12,
from /usr/include/yaml-cpp/node/iterator.h:13,
from /usr/include/yaml-cpp/node/impl.h:11,
from /usr/include/yaml-cpp/yaml.h:17,
from /home/freyr/exper/yamp-cpp/demo.cpp:3: /usr/local/include/boost/mpl/next_prior.hpp:29:8: note: ‘boost::mpl::next’ struct next
^~~~ CMakeFiles/helloDemo.dir/build.make:62: recipe for target 'CMakeFiles/helloDemo.dir/demo.cpp.o' failed make[2]: *** [CMakeFiles/helloDemo.dir/demo.cpp.o] Error 1 make[2]: Leaving directory '/home/freyr/exper/yamp-cpp/build' CMakeFiles/Makefile2:67: recipe for target 'CMakeFiles/helloDemo.dir/all' failed make[1]: *** [CMakeFiles/helloDemo.dir/all] Error 2 make[1]: Leaving directory '/home/freyr/exper/yamp-cpp/build' Makefile:83: recipe for target 'all' failed make: *** [all] Error 2
I see in latest https://github.com/jbeder/yaml-cpp/blob/master/include/yaml-cpp/node/detail/iterator.h there are no references to boost ad it is all std c++ alone.
How do I install latest version of libyaml-cpp-dev which has no boost dependencies ? I dont want to build and install from latest version as git cloning from master every time will not be a very secure practice.
yaml-cpp introduced boost dependency in version 0.5 and removed it in version 0.6. You need to upgrade your Ubuntu to a newer release or install yaml-cpp from sources, or install a version of yaml-cpp older than 0.5.
See: https://yaml-cpp.docsforge.com/#how-to-build
yaml-cpp 0.6.0 has been released! This release requires C++11, and no longer depends on Boost.
See also https://www.ubuntuupdates.org/package/core/hirsute/main/base/yaml-cpp - the current version of yaml-cpp in Ubuntu 21.4 is 0.6.3-9ubuntu1

Building TBB on Windows using MingW & Cmake

Hey I'm trying to build TBB on my Windows computer using MinGW & CMake. (gcc,,g++, ..)
I have already tried using the premade binaries but I keep getting undefined reference issues.
My cmake for the project I'm trying to import it in looks as following:
find_package(TBB REQUIRED tbb)
target_link_libraries(projectName PRIVATE ${TBB_IMPORTED_TARGETS})
I use the source code of https://github.com/oneapi-src/oneTBB/releases/tag/v2021.3.0 (latest)
and I make a build dir and cd into it and execute:
cmake .. -G "MinGW Makefiles"
followed by:
cmake --build .
also tried:
mingw32-make
Both result into
[ 1%] Building CXX object src/tbb/CMakeFiles/tbb.dir/address_waiter.cpp.obj
In file included from c:\users\refactor\downloads\onetbb-2021.3.0\onetbb-2021.3.0\include\oneapi\tbb\detail\_utils.h:26,
from C:\Users\Refactor\Downloads\oneTBB-2021.3.0\oneTBB-2021.3.0\src\tbb\address_waiter.cpp:17:
c:\users\refactor\downloads\onetbb-2021.3.0\onetbb-2021.3.0\include\oneapi\tbb\detail\_machine.h:67: error: ignoring '#pragma intrinsic ' [-Werror=unknown-pragmas]
67 | #pragma intrinsic(_mm_mfence)
|
compilation terminated due to -Wfatal-errors.
cc1plus.exe: all warnings being treated as errors
mingw32-make[2]: *** [src\tbb\CMakeFiles\tbb.dir\build.make:76: src/tbb/CMakeFiles/tbb.dir/address_waiter.cpp.obj] Error 1
mingw32-make[1]: *** [CMakeFiles\Makefile2:454: src/tbb/CMakeFiles/tbb.dir/all] Error 2
mingw32-make: *** [makefile:165: all] Error 2```
As mentioned in the comments there are issues building with MinGW with the latest versions of TBB.
The last version of TBB I was able to build was 2020.0 using this command (replace intel64 with ia32 for 32-bit):
mingw32-make compiler=gcc arch=intel64 runtime=mingw tbb tbbmalloc CPLUS="g++ -static-libstdc++ -static-libgcc"

Can not compile google test with MinGW on Windows

I tried to compile google test framework with MinGW on Windows following instructions from this post, but I got errors when executing make:
[ 25%] Building CXX object CMakeFiles/gtest.dir/src/gtest-all.cc.obj
In file included from d:/downloads/googletest-master/googletest/src/gtest-all.cc:45:0:
D:/downloads/googletest-master/googletest/src/gtest-port.cc: In static member function 'static void testing::internal::ThreadLocalRegistryImpl::StartWatcherThreadFor(DWORD)':
D:/downloads/googletest-master/googletest/src/gtest-port.cc:495:21: error: '::OpenThread' has not been declared
HANDLE thread = ::OpenThread(SYNCHRONIZE | THREAD_QUERY_INFORMATION,
^
make[2]: *** [CMakeFiles/gtest.dir/src/gtest-all.cc.obj] Error 1
make[1]: *** [CMakeFiles/gtest.dir/all] Error 2
make: *** [all] Error 2
Please help. I tried:
cmake -G "MSYS Makefiles" --with-pthreads=no
But got:
CMake Error: The source directory "D:/downloads/googletest-master/googletest/--with-pthreads=no" does not exist.
Specify --help for usage, or press the help button on the CMake GUI.
Thanks for answers.
cmake -G "MSYS Makefiles" --with-pthreads=no
I don't think --with-pthreads=no is a valid cmake option. CMake tries to interpret it as the source directory. Remove that option. I think google test needs pthreads anyways, that is why OpenThread is not declared, because it depends on pthreads.
If you're not using the MSYS shell, try to use the "MinGW Makefiles" generator for cmake.
cmake -G "MinGW Makefiles"
Then run make.

Error when compiling OpenCV for Qt

In order to use OpenCV in Qt, I have to compile it with MinGW by cmake.
Software are the following:
Qt 5.4.0
Opencv 2.4.11
CMake 3.2.2
MinGW version unknown, GCC 4.8.1
A fatal error occurred when I make file and I have no idea how to solve it at all.
[ 29%] Automatic moc for target opencv_highgui
Generating moc_window_QT.cpp
Exit code 0xc000007b
AUTOGEN: error: process for C:/opencvbuild/modules/highgui/moc_window_QT.cpp failed:
Exit code 0xc000007b
moc failed...
modules\highgui\CMakeFiles\opencv_highgui_automoc.dir\build.make:48: recipe for target 'modules/highgui/CMakeFiles/opencv_highgui_automoc' failed
mingw32-make[2]: *** [modules/highgui/CMakeFiles/opencv_highgui_automoc] Error 1
CMakeFiles\Makefile2:2066: recipe for target 'modules/highgui/CMakeFiles/opencv_highgui_automoc.dir/all' failed
mingw32-make[1]: *** [modules/highgui/CMakeFiles/opencv_highgui_automoc.dir/all] Error 2
Makefile:145: recipe for target 'all' failed
mingw32-make: *** [all] Error 2
These messages are shown in cmd.
Then I revised CMakeLists.txt, SET(CMAKE_AUTOMOC OFF)
modules\highgui\CMakeFiles\opencv_highgui_automoc.dir\build.make:64: recipe for target 'modules/highgui/qrc_window_QT.cpp' failed
Does anybody know a solution?
2 items to try.
Try running make with VERBOSE=1 to increase the output on the makefile. That should give you a better idea of what is wrong.
Try running with cmake-gui, then turn on advanced mode to check out what CMake found for the different Qt5 dependencies. On Mac, I install the latest Qt to my home directory, causing me to have to manually set variables. This is what it looks like for me.
Hopefully this provides some useful information.

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