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.
Related
I am creating a C library which is to be built with cmake, using Mac OS for development. In the CMakeList.txt, I have the following
#htslib
find_package(htslib REQUIRED)
include_directories(${HTSLIB_INCLUDE_DIR})
target_link_libraries(projectname ${HTSlib_LIBRARIES})
which outputs upon cmake ..
Found hstlib
However, upon make, I'm getting linker errors:
clang: error: linker command failed with exit code 1 (use -v to see invocation)
So...it can find the library, and the library is definitely installed with sudo make install, but there are linking errors only with this library.
(1) I'm guessing that find_package(htslib REQUIRED) is finding something else. How do I find out what?
(2) How do I explicitly write in CMakeList.txt to find the library which I know has been installed correctly?
Use VERBOSE=1 make to see the linker output. Search for -lhtslib
Read the documentation for the specific Find<LIB>.cmake.
Your specific questions:
"How do I find what CMake found": Use cmake-gui or ccmake. They both show the same info, but one is a GUI and the other is a Curses interface. In the advanced mode ("t" on ccmake) you will find all the variables for the searched packages. Additionally, you may use MESSAGE(STATUS "Found htslib at: ${htslib_LIBRARIES}").
"How to explicitly write in CMakeLists.txt where the library is?" Please, do not do that! CMake is meant for abstracting exactly this kind of information away. You have two options, first the good one: configure cmake on the command line (or in the GUIs mentioned above) to get a CMAKE_MODULES_PATH or a more specific hint to the library -D htslib_PATH=/usr/local/.../ (pointing to the dir where libhts.dylib resides). The worse solution would be to provide a HINT to find_package. find_package(htslib REQUIRED PATH /usr/local/lib) or find_package(htslib REQUIRED HINT /usr/local/lib /some/second/path/where/it/may/be).
Solution
Your linked project has a custom FindHTSlib.cmake link. This one uses pkg_config to configure the library. To replicate your problem, I used brew to install htslib. The pkg-config file can be found (for me, but brew info htslib tells you) under /usr/local/Cellar/htslib/1.8/lib/htslib.pc. So, let's give CMake the required hint.
I couldn't test this, because for me it found the htslib package directly with no further hints.
git clone https://github.com/D-Lo/bamdb # I am using version f5f03d0
mkdir -p bamdb/build; cd bamdb/build
brew install ck htslib lmdb
cmake .. # -G Ninja recommended, but needs brew install ninja
make # lot's of missing symbols
I would recommend to change in CMakeLists.txt the minimum required version of CMake from 2.8 to 3.10 (or at least 3.6).
This is the error I get:
[ 62%] Linking C shared library libbamdb.dylib
/usr/local/Cellar/cmake/3.11.1/bin/cmake -E cmake_link_script CMakeFiles/libbamdb.dir/link.txt --verbose=1
/Library/Developer/CommandLineTools/usr/bin/cc -Wall -g -std=gnu99 -fPIC -dynamiclib -Wl,-headerpad_max_install_names -o libbamdb.dylib -install_name #rpath/libbamdb.dylib CMakeFiles/libbamdb.dir/src/bam_api.c.o CMakeFiles/libbamdb.dir/src/bam_lmdb.c.o CMakeFiles/libbamdb.dir/src/bamdb.c.o
Undefined symbols for architecture x86_64:
"_bam_destroy1", referenced from:
_get_bam_row in bam_api.c.o
_deserialize_func in bam_lmdb.c.o
This can be fixed by adding the following line in the CMakeLists.txt, after the line add_library(libbamdb ${SOURCES}):
target_link_libraries(libbamdb ${LIBS})
Some further notes: you now have a library with a main function. This is because ${SOURCES} is used to build the executable and the library. That can have unexpected side effects. Unless it's needed, don't do it.
I would like to modify OpenSSL code and then debug it in my IDE (QTCreator).
I have downloaded the OpenSSL source code, built it according to ./config with debugging symbols, and deployed it in non-system folder. Still, when I make modifications to the library, the changes are not effective in the debugged program.
For instance, I attempt to modify handshake process and test the results using the s_client app. Nevertheless, the s_client app points to the system version of OpenSSL. Namely, s_client includes <openssl/...> (which is located in /usr/local/...).
I would like it to point to the just installed/modified version of openssl in different folder. There's a catch though. I have figured only one way how to do it, by modifying the original OpenSSL makefile, which is just huge and the task seems overwhelming.
Does anyone has any idea how to approach this issue? Please note that I would like to keep the system version of the OpenSSL operational (symbolic link not suitable).
I run the Ubuntu 16.04 LTS. The output of ldd /my/version/of/openssl is
linux-vdso.so.1 => (0x00007ffd9a3d6000)
libssl.so.1.1 => /usr/local/lib/libssl.so.1.1 (0x00007f04523f8000)
libcrypto.so.1.1 => /usr/local/lib/libcrypto.so.1.1 (0x00007f0451f6a000)
libpthread.so.0 => /lib/x86_64-linux-gnu/libpthread.so.0 (0x00007f0451d4d000)
libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007f0451983000)
libdl.so.2 => /lib/x86_64-linux-gnu/libdl.so.2 (0x00007f045177f000)
/lib64/ld-linux-x86-64.so.2 (0x00007f0452668000)
With the help of the two guys (see comments), I was able to figure out the problem. First, make sure you compile OpenSSL with --prefix and --openssl directories properly set.
Once OpenSSL installed, you need your code (apps of OpenSSL) to be calling/linking your new version of OpenSSL. In QtCreator you can achieve this by setting the LD_LIBRARY_PATH to the directory with the library files libcrypto.so.1 and libssl.so.1. The setting is done in Projects -> Run environment -> (add LD_LIBRARY_PATH into system environment).
Moreover, you can check what libraries are called by the binary manually, by entering the directory with the binary and calling command ldd ./openssl from the terminal. This way, you will see what libraries are called (it should be your own version, not the system libraries). Further, you can set LD_LIBRARY_PATH from terminal, optionally with export command in front of it, to achieve permanent effect (lasting whole terminal session). In total, you could call
export LD_LIBRARY_PATH=/path/to/your/lib.
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.
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 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.