Use self-compiled OpenSSL to compile bitcoin on fedora 21 - c++

Right now I can build the bitcoin-qt and execute it but it immediately exits with this Error:
OpenSSL appears to lack support for elliptic curve cryptography. For
more information, visit
https://en.bitcoin.it/wiki/OpenSSL_and_EC_Libraries
The website only links to some outdated rpms for fedora 19 but it is also mentioned one could "compile [their] own OpenSSL and use this".
I can download and compile OpenSSL but I never managed to tell bitcoin where OpenSSL is located.
What I tried yesterday: (instructions from https://opennet.hackpad.com/ep/pad/static/HqezreF8xmh )
install dependecies
export OPENSSL_PREFIX=/tmp/folder1
Download and unzip openssl-1.0.2a source code
CC='cc -fPIC' ./config --prefix=$OPENSSL_PREFIX
make all install_sw
Download and unzip bitcoin source code
./autogen.sh
./configure SSL_CFLAGS=' ' SSL_LIBS="$OPENSSL_PREFIX/lib/libssl.a $OPENSSL_PREFIX/lib/libcrypto.a -ldl" CRYPTO_CFLAGS=' ' CRYPTO_LIBS=' '
make
But this failed with
libbitcoin_util.a(libbitcoin_util_a-random.o): In function `RandAddSeed()':
/tmp/test2/bitcoin/src/random.cpp:42: undefined reference to `RAND_add'

If you don't mind overwriting your current version of openssl, try to do an "update" to openssl:
./config --prefix=/usr --openssldir=/usr/local/openssl shared
make
make test
make install
Source: https://stackoverflow.com/a/22952749/2084795

Related

Apps cannot detect C++ poco even though I have installed it

I want to be able to make and run this particular library on my computer. Currently going through the INSTALL file. I am currently at the point:
After extracting the Poco (Complete Edition) source archive, the configure
script should be called with the following parameters:
./configure --omit=Crypto,Net,NetSSL_OpenSSL,Data/ODBC,Data/MySQL \
--no-tests --no-samples
This line avoids building the parts of Poco which are dependent on third-party
libraries, and are not required for openBliSSART.
You can also specify a prefix where Poco should be installed, but in most cases
you should leave the default /usr/local.
I can't seem to run the options, so I simply ran ./configure, this seemed to have worked till the point where I encountered:
checking for fftw_plan_dft_r2c_1d in -lfftw3... yes
checking for Poco (Enterprise)... no
configure: error: Need Poco Enterprise v1.3.6+!
But the fact is, that I have installed Poco already on the system through a brew install poco and downloaded the library from their source website and compiled it ground up. looking back at INSTALL:
Depending on where you have installed Poco, you may have to set the
LD_LIBRARY_PATH environment variable to contain the Poco "lib" directory,
or run the ldconfig tool. The following lines work with Ubuntu and openSUSE
($ indicates the shell prompt):
$ sudo sh -c 'echo <prefix>/lib > /etc/ld.so.conf.d/poco.conf'
$ sudo ldconfig
where <prefix> is the Poco install prefix (by default /usr/local).
Now when I do a simple sudo find / -name poco, I get:
/usr/local/var/homebrew/linked/poco
/usr/local/opt/poco
/usr/local/Cellar/poco
find: /private/var/db/ConfigurationProfiles/Store: Operation not permitted
find: /private/var/folders/pq/xchc5hxj02d754txf8nml5f00000gn/0/SafariFamily: Operation not permitted
find: /private/var/folders/pq/xchc5hxj02d754txf8nml5f00000gn/0/com.apple.LaunchServices.dv: Operation not permitted
find: /private/var/folders/pq/xchc5hxj02d754txf8nml5f00000gn/0/com.apple.nsurlsessiond: Operation not permitted
find: /private/var/folders/pq/xchc5hxj02d754txf8nml5f00000gn/0/com.apple.routined: Operation not permitted
find: /private/var/folders/zz/zyxvpxvq6csfxvn_n00000y800007k/0/com.apple.nsurlsessiond: Operation not permitted
find: /private/var/folders/zz/zyxvpxvq6csfxvn_n00000s4000069/0/com.apple.nsurlsessiond: Operation not permitted
find: /private/var/folders/zz/zyxvpxvq6csfxvn_n00000s4000069/0/com.apple.routined: Operation not permitted
/Users/sharanduggirala/Library/Logs/Homebrew/poco
/Users/sharanduggirala/Documents/of_v0.9.8_osx_release/libs/poco
/Users/sharanduggirala/Documents/of_v0.9.8_osx_release/scripts/apothecary/formulas/poco
find: /dev/fd/3: Not a directory
find: /dev/fd/4: Not a directory
Also, it looks like while building poco, I did a ./configure --static. Would this have affected my compilation? How do I link this library?
I have already used the command ./configure --with-poco-prefix=/usr/local/opt/poco which doesn't really change anything.
Notes relating to S.M.'s Answer
I tried this, but got the error:
brew install poco --with-static ⏎
==> Downloading https://pocoproject.org/releases/poco-1.9.0/poco-1.9.0-all.tar.gz
######################################################################## 100.0%
Error: SHA256 mismatch
Expected: 028de410fc78d5f9b1ff400e93ec3d59b9e55a0cbbf0d8fec04636882b72ea45
Actual: 0387bf0f9d313e2311742e1ad0b64e07f2f3e76039eed20e3b9aa9951b88e187
Archive: /Users/sharanduggirala/Library/Caches/Homebrew/poco-1.9.0.tar.gz
To retry an incomplete download, remove the file above.
I also tried:
./configure --static ⏎
configure: error: unrecognized option: `--static'
Try `./configure --help' for more information
Do not install poco from sources. Use brew install poco. If you want the same like ./configure --static use brew install poco --with-static.

ICU library build error (telegram-desktop for debian-jessie)

I'm trying to build telegram-desktop on RPi 3 (debian-jessie) following this guide. I encuntered this error involving ICU library, so that I've done the following steps:
downloaded ICU 58.1 sorce file
decompressed in ~/ and configured with ./configure
commented out the LDFLAGSICUDT flag in ~/icu/source/config/mh-linux as described in another StackOverflow question
sudo make and make check (fine)
sudo make install
At this point it is prescribed in the above answer "to make a symbolic link from /usr/local/libicuXXX.a to /usr/lib/libicuXXX.a". I guess I have to run
sudo ln -s /usr/local/libicutu.a /usr/lib/libicutu.a
(it's right?) but the problem is that I can't find /usr/local/lib/libicutu.a!

RabbitMQ C++ client for old Debian

I have an old Debian (Lenny), on which I develop an application that should connect to RabbitMQ.
I downloaded the official C++ client rabbitmq-c-0.8.0 from https://github.com/alanxz/rabbitmq-c/releases/tag/v0.8.0 , but unfortunately, I can't compile it on my old Debian:
wget https://github.com/alanxz/rabbitmq-c/archive/v0.8.0.tar.gz
tar zxvf v0.8.0.tar.gz
autoreconf -i
Result:
autoreconf -i
/usr/share/aclocal/libmcrypt.m4:17: warning: underquoted definition of AM_PATH_LIBMCRYPT
/usr/share/aclocal/libmcrypt.m4:17: run info '(automake)Extending aclocal'
/usr/share/aclocal/libmcrypt.m4:17: or see http://sources.redhat.com/automake/automake.html#Extending-aclocal
Makefile.am:6: Libtool library used but `LIBTOOL' is undefined
Makefile.am:6: The usual way to define `LIBTOOL' is to add `AC_PROG_LIBTOOL'
Makefile.am:6: to `configure.ac' and run `aclocal' and `autoconf' again.
Makefile.am:6: If `AC_PROG_LIBTOOL' is in `configure.ac', make sure
Makefile.am:6: its definition is in aclocal's search path.
autoreconf2.50: automake failed with exit status: 1
Version of automake I have (and I can't upgrade it): 1:1.10.1-3
Version of libtool I have (and I can't upgrade it as well): 1.5.26-4+lenny1
Does anyone know how to build the RabbitMQ client on the old OS I use?
Many thanks!!!
Eventually, the best solution was to move to ubuntu 14+

How do I specify LDFLAGS and CPPFLAGS for ./configure?

I am using a Mac running OS X 10.8.3. I am trying to compile cgminer 3.0.0. On my first run of ./configure I got the message:
checking for LIBCURL... no
checking for LIBCURL... no
configure: error: Missing required libcurl dev >= 7.18.2
So I installed the latest version of libcurl using homebrew:
brew install curl
That seemed to do the trick. I got this message:
downloaded: /Library/Caches/Homebrew/curl-7.30.0.tar.gz
==> ./configure --prefix=/usr/local/Cellar/curl/7.30.0
==> make install
==> Caveats
This formula is keg-only: so it was not symlinked into /usr/local.
Mac OS X already provides this software and installing another version in
parallel can cause all kinds of trouble.
The libcurl provided by Leopard is too old for CouchDB to use.
Generally there are no consequences of this for you. If you build your
own software and it requires this formula, you'll need to add to your
build variables:
LDFLAGS: -L/usr/local/opt/curl/lib
CPPFLAGS: -I/usr/local/opt/curl/include
==> Summary
/usr/local/Cellar/curl/7.30.0: 75 files, 2.0M, built in 61 seconds
Okay, so it's installed but not symlinked into /usr/local, that's fine with me. I tried this:
export LDFLAGS=-L/usr/local/opt/curl/lib
export CPPFLAGS=-I/usr/local/opt/curl/include
./configure
But I got the same message: configure: error: Missing required libcurl dev >= 7.18.2
So I tried this:
env LDFLAGS=-L/usr/local/opt/curl/lib CPPFLAGS=-I/usr/local/opt/curl/include ./configure
I'm still getting the "missing required libcurl" message. Any ideas?
After some more thorough investigation, I determined that the configure file for cgminer does not pay attention to LDFLAGS or CPPFLAGS when testing for libcurl. Instead, it checks for LIBCURL_CFLAGS and LIBCURL_LIBS. So, I tried:
export LIBCURL_CFLAGS=-I/usr/local/opt/curl/include
export LIBCURL_LIBS=-L/usr/local/opt/curl/lib
./configure
and I got:
checking for LIBCURL... yes
And the rest of the configuration went off without a hitch. SUCCESS!

How do I install and build against OpenSSL 1.0.0 on Ubuntu?

You can consider this a follow-up question to How do I install the OpenSSL C++ library on Ubuntu?
I'm trying to build some code on Ubuntu 10.04 LTS that requires OpenSSL 1.0.0.
Ubuntu 10.04 LTS comes with OpenSSL 0.9.8k:
$ openssl version
OpenSSL 0.9.8k 25 Mar 2009
So after running sudo apt-get install libssl-dev and building, running ldd confirms I've linked in 0.9.8:
$ ldd foo
...
libssl.so.0.9.8 => /lib/i686/cmov/libssl.so.0.9.8 (0x00110000)
...
libcrypto.so.0.9.8 => /lib/i686/cmov/libcrypto.so.0.9.8 (0x002b0000)
...
How do I install OpenSSL 1.0.0 and the 1.0.0 development package?
Update: I'm writing this update after reading SB's answer (but before trying it), because it's clear I need to explain that the obvious solution of downloading and installing OpenSSL 1.0.0 doesn't work:
After successfully doing the following (recommended in the INSTALL file):
$ ./config
$ make
$ make test
$ make install
...I still get:
OpenSSL 0.9.8k 25 Mar 2009
...and:
$ sudo apt-get install libssl-dev
Reading package lists... Done
Building dependency tree
Reading state information... Done
libssl-dev is already the newest version.
The following packages were automatically installed and are no longer required:
linux-headers-2.6.32-21 linux-headers-2.6.32-21-generic
Use 'apt-get autoremove' to remove them.
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
...and (just to make sure) after rebuilding my code, ldd still returns the same thing.
Update #2: I added the "-I/usr/local/ssl/include" and "-L/usr/local/ssl/lib" options (suggested by SB) to my makefile, but I'm now getting a bunch of undefine reference compile errors, for example:
/home/dspitzer/foo/foo.cpp:86: undefined reference to `BIO_f_base64'
/home/dspitzer/foo/foo.cpp:86: undefined reference to `BIO_new'
/usr/local/ssl/include/ contains only an openssl directory (which contains numerous .h files), so I also tried "-I/usr/local/ssl/include/openssl" but got the same errors.
Update #3: I tried changing the OpenSSL includes from (for example):
#include <openssl/bio.h>
...to:
#include "openssl/bio.h"
...in the .cpp source file but still get the same undefined reference errors.
Update #4: I now realize those undefined reference errors are linker errors. If I remove the "-L/usr/local/ssl/lib" from my Makefile, I don't get the errors (but it links to OpenSSL 0.9.8). The contents of /usr/local/ssl/lib/ are:
$ ls /usr/local/ssl/lib/
engines libcrypto.a libssl.a pkgconfig
I added -lcrypto, and the errors went away.
Get the 1.0.0a source from here.
# tar -xf openssl-1.0.0a.tar.gz
# cd openssl-1.0.0a
# ./config
# sudo make install
Note: if you have man pages build errors on modern systems, use make install_sw instead of make install.
This puts it in /usr/local/ssl by default
When you build, you need to tell gcc to look for the headers in /usr/local/ssl/include and link with libs in /usr/local/ssl/lib. You can specify this by doing something like:
gcc test.c -o test -I/usr/local/ssl/include -L/usr/local/ssl/lib -lssl -lcrypto
EDIT DO NOT overwrite any system libraries. It's best to keep new libs in /usr/local. Overwriting Ubuntu defaults can be hazardous to your health and break your system.
Additionally, I was wrong about the paths as I just tried this in Ubuntu 10.04 VM. Fixed.
Note, there is no need to change LD_LIBRARY_PATH since the openssl libs you link against by default are static libs (at least by default - there might be a way to configure them as dynamic libs in the ./config step)
You may need to link against libcrypto because you are using some calls that are built and defined in the libcrypto package. Openssl 1.0.0 actually builds two libraries, libcrypto and libssl.
EDIT 2 Added -lcrypto to gcc line.
Instead of:
$ ./config
$ make
$ make test
$ make install
Do:
$ sudo ./config --prefix=/usr
$ sudo make
$ sudo make test
$ sudo make install
This will help you update to openssl 1.0.1g to patch for CVE-2014-0160 (Heartbleed).
OpenSSL Security Advisory [07 Apr 2014]
TLS heartbeat read overrun (CVE-2014-0160)
A missing bounds check in the handling of the TLS heartbeat extension can be
used to reveal up to 64k of memory to a connected client or server.
Only 1.0.1 and 1.0.2-beta releases of OpenSSL are affected including
1.0.1f and 1.0.2-beta1.
Thanks for Neel Mehta of Google Security for discovering this bug and to
Adam Langley and Bodo Moeller for
preparing the fix.
Affected users should upgrade to OpenSSL 1.0.1g. Users unable to immediately
upgrade can alternatively recompile OpenSSL with -DOPENSSL_NO_HEARTBEATS.
1.0.2 will be fixed in 1.0.2-beta2.
Source: https://www.openssl.org/news/secadv_20140407.txt
Here's what solved it for me:
Upgrade latest version OpenSSL on Ubuntu
Transcribing the main information:
Download the OpenSSL v1.0.0g source:
$ wget http://www.openssl.org/source/openssl-1.0.0g.tar.gz
Unpack the archive and install:
$ tar xzvf openssl-1.0.0g.tar.gz
$ cd openssl-1.0.0g
$ ./config
$ make
$ make test
$ sudo make install
All files, including binaries and man pages are install under the directory /usr/local/ssl. To ensure users use this version of OpenSSL instead of the previous version you must update the paths for man pages and binaries.
Edit the file /etc/manpath.config adding the following line before the first MANPATH_MAP:
MANPATH_MAP /usr/local/ssl/bin /usr/local/ssl/man
Update the man database (I honestly can't remember and don't know for sure if this command was necessary - maybe try without it and at the end when testing if the man pages are still the old versions come back and run mandb):
sudo mandb
Edit the file /etc/environment and insert the path for OpenSSL binaries (/usr/local/ssl/bin) before the path for Ubuntu's version of OpenSSL (/usr/bin). My environment file looks like this:
PATH="/usr/local/sbin:/usr/local/bin:/usr/local/ssl/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games"
Logout and login and test:
$ openssl version
OpenSSL 1.0.0g 18 Jan 2012
Also test the man pages by running man openssl and at the very bottom in the left hand corner it should report 1.0.0g.
Note that although the users will now automatically use the new version of OpenSSL, existing programs (e.g. Apache) may not as they are linked against the libraries from the Ubuntu version.