I'm trying to compile a static version of Tor with MinGW-w64 (MSYS 2). I've downloaded the Tor source (tor-0.3.1.8) and according to the INSTALL and COMPILE file I've compiled static version of OpenSSL (openssl-1.1.0g), zLib (zlib-1.2.11) and Libevent (libevent-2.1.8-stable)
To compile OpenSSL I've used
perl Configure mingw no-shared no-dso --prefix=/usr/local/openssl --openssldir=/usr/local/openssl
make depend
make
make install
The compilation success and I can find the libssl.a and libcrypto.a in /usr/local/openssl/lib/. I've used no-share and no-dso as INSTALL file in tor source dir declares.
To compile zLib I've used
make -fwin32/Makefile.gcc
To compile Libevent I've used
./configure --prefix=/usr/local/libevent --disable-shared --enable-static --with-pic
make
make install
The compilation is ok and I can find all files in /usr/local/libevent. I've used --disable-shared --enable-static --with-pic as written in INSTALL file inside tor source code.
After I've launched the configure script for Tor
./configure --enable-static-tor --with-libevent-dir=/usr/local/libevent --with-openssl-dir=/usr/local/openssl --with-zlib-dir=/home/Nicola/tor-mingw/zlib-1.2.11
as written in INSTALL file.
The configuration script end with error after it has checked Libevent with success
checking for openssl directory... (system)
checking whether we need extra options to link openssl... (none)
configure: error: "You must specify an explicit --with-openssl-dir=x option when using --enable-static-openssl"
I've tried adding / after each dir, but nothing changes. Is it a script error that can be solved setting manually TOR_OPENSSL_LIBS with ?
TOR_OPENSSL_LIBS="/usr/local/openssl/lib/libssl.a /usr/local/openssl/lib/libcrypto.a"
Thank you for your help
Try adding --enable-static-openssl to your Tor configure command to tell it to link against a static OpenSSL library. You'll need the same for libevent and zlib.
For reference, here's what I use to build Tor (it's not completely static like you are going for):
./configure --prefix=/opt/tor-$VERSION --sysconfdir=/etc --localstatedir=/var \
--enable-static-openssl --with-openssl-dir=/opt/openssl \
--enable-lzma --enable-zstd \
--with-tor-user=tor --with-tor-group=tor
On a side note, if you can build OpenSSL with the enable-ec_nistp_64_gcc_128 flag, then ECDH will be much faster.
I use this to build static OpenSSL library for Tor:
./config no-shared zlib-dynamic \
--prefix=/opt/openssl --openssldir=/opt/openssl \
-fPIC enable-ec_nistp_64_gcc_128
Hope that helps.
Related
I'm trying to install fftw-2.1.5 as it is required by the GADGET3 code version I need to use. I had no issues building it on my Linux machine (running Ubuntu 22.04), but on my M1 MacBook Pro (running macOS Monterey 12.4) it crashes at the configure step.
Running:
./configure --prefix=path/to/local/install \
--enable-mpi \
--enable-type-prefix \
--with-gcc
I got the following error message:
checking build system type... configure: error: /bin/sh ./config.sub -apple-darwin21.5.0 failed
It seems that the configure script is not properly parsing the details of the MacBook, hence it crashes before testing the rest of the dependencies...
Disclaimer: I am fairly new to macOS and I have never had to use autotools before.
I found a similar issue here, so credits to the people that documented it there. I am unsure if all the following steps are required but they certainly solved my issue:
I renamed configure.in to configure.ac
I downloaded and applied all the patches from this website. I simply copied the text of each patch into new files patch_filename and ran $ patch < patch_filename in the main fftw-2.1.5 directory. As I renamed configure.in to configure.ac, when applying patch 05_ac_define_syntax.diff it will prompt the user to specify the path to the file to patch, i.e. configure.ac.
(OPTIONAL) I also needed OpenMP support so additionally I needed to modify lines 249, 251, 253, 255 and 257 so that the variables omp_enabler and CFLAGS read as omp_enabler="$CC -fopenmp" and CFLAGS="$save_CFLAGS -fopenmp", where CC=gcc in my case.
I ran $ autoupdate followed by $ autoreconf -vfi in the main fftw-2.1.5 directory.
I ran the configure script with the desired flags, e.g. for double precision + MPI support:
$ ./configure --prefix=path/to/local/install \
--enable-mpi \
--enable-type-prefix \
--with-gcc \
LDFLAGS=-L/opt/homebrew/lib \
CFLAGS=-I/opt/hombrew/include
Finally, the standard make into make check and make install did the trick
I download curl7.40 source code, and I have already compile openssl
1.0.2 source code, Now I want to compile curl with openssl 1.0.2.
./configure --prefix=/usr/local/curl-7.40.0 --with-ssl
--with-libssl-prefix=/usr/local/openssl-1.0.2
make && make install
After I install, I ldd curl library but still link with system default library.
ldd libcurl.so
linux-vdso.so.1 => (0x00007fff2db2e000)
libidn.so.11 => /usr/lib/x86_64-linux-gnu/libidn.so.11 (0x00007fafb9b6e000)
librtmp.so.0 => /usr/lib/x86_64-linux-gnu/librtmp.so.0 (0x00007fafb9954000)
libssl.so.1.0.0 => /lib/x86_64-linux-gnu/libssl.so.1.0.0 (0x00007fafb96f5000)
libcrypto.so.1.0.0 => /lib/x86_64-linux-gnu/libcrypto.so.1.0.0
(0x00007fafb931b000)
...
UPDATE
After some search, I use below command to config.
./configure --prefix=/usr/local/curl-7.40.0 --with-ssl=/usr/local/openssl-1.0.2
But when make install, it will show below error information.
../lib/.libs/libcurl.so: undefined reference to `SSLv2_client_method'
collect2: error: ld returned 1 exit status
The problem is likely with how you have build the OpenSSL library.
It is likely you have built openssl with SSLv2 disabled as some distributions have SSLv2 disable by default. Look at the ./config for your system when you are compiling OpenSSL, and find the option that controls the OPENSSL_NO_SSL2 preprocessor flag.
In order to use proper version of openssl while making from source, you can make openssl like this:
cd <path-to-openssl-dir>
./config enable-ssl2 enable-ssl3 --prefix=<path-to-openssl-install-dir>
Then, you can link your curl version properly to openssl by:
./configure --with-ssl=<path-to-openssl-install-dir>
SSLv2_client_method() is used in lib/vtls/openssl.c, line 1575 with a check for availability of this function via autoconf. It seems to me that autoconf's AC_CHECK_FUNCS incorrectly finds your system installation of openssl which has SSLv2 enabled before #includeing your own installation of openssl-1.0.2 which doesn't have SSLv2_client_method() and thus assumes the function to be available.
Try passing CFLAGS=-I/usr/local/openssl-1.0.2/include or even "CFLAGS=-I/usr/local/openssl-1.0.2/include -DOPENSSL_NO_SSL2" as arguments to ./configure to force openssl.c to make do without the SSLv2_client_method() incorrectly assumed to be available.
I am trying to build a cross compiler. I follow this tutorial: http://wiki.osdev.org/GCC_Cross-Compiler
I installed binutils in in /opt/cross. now I try to install gcc-4.7.4 with mpfr-2.4.2. I used commands to prepare and configure:
export PREFIX="$HOME/opt/cross"
export TARGET=i686-elf
export PATH="$PREFIX/bin:$PATH"
mv gmp-4.3.2 gcc-4.7.4/gmp
mv mpfr-2.4.2 gcc-4.7.4/mpfr
mv mpc-0.8.1 gcc-4.7.4/mpc
# i am in usr/src directory
mkdir build-gcc
cd build-gcc
../gcc-4.7.4/configure --target=$TARGET --prefix="$PREFIX" --disable-nls --enable-languages=c,c++ --without-headers
Now, i use make all-gcc to build, but I receive following error: configure: error: libmpfr not found or uses a different ABI (including static vs shared).
Why is this happening and how I can fix it?
Thanks!
You can check how "configure" checks if libmpfr is available (where configure looks for it) or just give the path to your libmpfr - with probably --enable-libmpfr=/path/ or something like this.
The second option is to give gcc configure option to disable using of mpfr (--disable-mpfr ?)
I assume that you are trying to compile gcc for another architecture than your host. Maybe gcc configure found libmpfr but it is mpfr from your host and not from your target architecture? You may take a look into config.log file if there is any and check which mpfr is using by configure.
Did you try to link libraries with export LD_LIBRARY_PATH=./gcc-4.7.4/mpfr/.libs
I'm working to compile the Thrift 0.9.0 binary statically in a CentOS VM. I get the issue that the libthrift.a binary is not being created. I am using a vagrant box to run centos:
https://github.com/2creatives/vagrant-centos/releases/download/v6.5.1/centos65-x86_64-20131205.box
Once I ssh to the vagrant box I run the following commands:
wget https://archive.apache.org/dist/thrift/0.9.0/thrift-0.9.0.tar.gz
tar -zxvf thrift-0.9.0.tar.gz
cd thrift-0.9.0
./configure --enable-static
make
This will run but I ran a find command (sudo find / -name "*.a") on the system to see if there was any ".a" files made and the only file that was made was "libparse.a" which doesn't seem right. From my understanding it should be "libthrift.a".
Searching through the config.log file it says that it does want to build the static libraries:
configure:11944: checking whether to build static libraries
configure:11948: result: yes
Looking at more locations in the log file that has the keyword "static" reveals potential places that may be errors.
configure:9028: checking if gcc static flag -static works
configure:9056: result: no
configure:13915: checking if g++ static flag -static works
configure:13943: result: no
lt_cv_prog_compiler_static_works=no
lt_cv_prog_compiler_static_works_CXX=no
The full log file is here: http://www.filehosting.org/file/details/449460/staticThriftErrorLog.rtf
Any help is appreciated
I was able to generate the libthrift.a file. After running the command for the extra dependancies mentioned in my comment I forgot to run the make command. So after doing the make command I found the libthrift.a file in "thrift-0.9.0/lib/cpp/.libs/". Interestingly enough, even after fixing the dependencies, config.log still had the same potential problem areas regarding the gcc/g++ static flag and static compiler.
Specifically the dependency command is as follows:
sudo yum install automake libtool flex bison pkgconfig gcc-c++ boost-devel libevent-devel zlib-devel python-devel ruby-devel openssl-devel.x86_64
Edit: After getting advice on the Jira ticket, it turns out the specific vagrant box I was using was causing the errors. Using the VM he linked I was able to successfully build Thrift using the provided instructions. (Jira ticket https://issues.apache.org/jira/browse/THRIFT-2559)
I was previously running apache 2.2.20 and openssl 1.0.0e. I installed openssl 1.0.1, then downloaded the tarball for apache 2.4.1 and installed apr 1.4.6 & apr-util 1.4.1 with --prefix=/usr/local. I configured apache2 with:
sudo ./configure --prefix=/usr/local/apache2 --enable-mods-shared=all
--enable-deflate --enable-proxy --enable-proxy-balancer --enable-proxy-http
--enable-rewrite --enable-cache --enable-mem-cache --enable-ssl --enable-headers
--with-mpm=worker --with-included-apr
But after running sudo make I get an error:
httpd-2.4.1/support/ab.c:2227: undefined reference to `SSLv2_client_method'
What is causing this error and how do I correct it?
You may have built openssl with SSLv2 disabled, some distributions have that disabled (Debian, starting from 7.0 -Wheezy- is one). Looking at the source, it looks like if you define the OPENSSL_NO_SSL2 preprocessor flag, apache won't call the SSLv2_client_method() function.
You can also download openssl's tarbal and compile openssl with
./config shared no-ssl2
This will set the flag OPENSSL_NO_SSL2 that Jon Lin mentioned.
It has nothing to do with OpenSSL compilation. PHP is the culprit which is causing the error.
(Note: The is another issue with OpenSSL which might prevent u from generating openssl.so and opencrypto.so shared libraries)
Here is the overview of how it happened. PHP compiles its compilation and when "make install" is given it copies the libphp*.so to /usr/local/apache2/modules.
The source code for this error is openssl.c in /usr/local/php-5.5.3/ext/openssl
So the simple solution is to handle it in the top level Makefile. By adding
CPPFLAGS = -D_REENTRANT -DTHREAD=1 -DOPENSSL_NO_SSL2
Make the above change AFTER you run the configure script. Hope this helps :)
Try with another Apache version. With Apache 2.2.15 the error was present but when i change to Apache 2.2.27 the "reference to `SSLv2_client_method" error simply disappeared
The compilation line is:
./configure --with-ssl --enable-ssl
That's all.