Cygwin cross-compiling OpenSSL 1.1.0e version

Source: Internet
Author: User


Citation: The platform is based on Atmel AT91RM9200-DK, the toolchain is provided by a third party, there is a need to use TS (time server) in the work, and the TS is based on the NTP (Network time protocal) protocol, and NTP is officially given the NTP protocol package, Other vendor implementations are based on this package to implement the deployment of their own TS. The protocol packages for NTP include Protocol implementation libraries, NTP services, NTP clients, and other assistive tools. The NTP protocol implementation is secure, requires SSL-based work, requires a new version of OpenSSL to work, and the existing OpenSSL 0.98-based implementation fails to compile. Based on the above considerations, a library of OpenSSL 1.1.0e needs to be compiled with the existing toolchain.

The existing toolchain is based on the Cygwin 32 work, so the solution is to do the Cygwin under the OpenSSL 1.1.0e cross-compilation.
The key compilation configuration is as follows:
1. Expand the OpenSSL 1.1.0e
#tar XZVF openssl-1.1.0e.tar.gz
2. Configuring the compilation Environment
$ ls/usr/local/arm/3.3.4/bin/
Arm-linux-addr2line.exe arm-linux-c++.exe arm-linux-g++.exe arm-linux-gccbug arm-linux-nm.exe Arm-linux-ranlib.exe Arm-linux-strings.exe
Arm-linux-ar.exe Arm-linux-c++filt.exe Arm-linux-gcc.exe Arm-linux-gcov.exe Arm-linux-objcopy.exe Arm-linux-readelf.exe Arm-linux-strip.exe
Arm-linux-as.exe arm-linux-cpp.exe arm-linux-gcc-3.3.4 arm-linux-ld.exe arm-linux-objdump.exe Arm-linux-size.exe TEST.c
#export path= $PATH:/usr/local/arm/3.3.4/bin/
$./configure linux-armv4 No-asm Shared--prefix=/usr/local/arm-ssl
This command configures the build target of OpenSSL to be an ARM processor-based Linux version, and if it is not, it will encounter platform-related variability issues such as Pthread's library compilation during the change of medical ethics. (Note: If not LINUX-ARMV4 configuration, and with--host=arm-linux such as accompany, but will be an error of the OH)
$vi Makefile
Because configure does not specify the tool chain information (compiler name, header file path, library path, sysroot), configure script generated makefile and toolchain do not match, need to manually modify Makfile. The modified items are as follows:
1) Cross compiler prefix
cross_compile=
Revision changed to
Cross_compile= arm-linux-
2) Compile parameters, add a command
Cflags+=-i/usr/local/arm/3.3.4/arm-linux/sys-root/usr/include
3) Link Parameters
ldflags=
Revision changed to
Ldflags=-l/usr/local/arm/3.3.4/arm-linux/sys-root/lib-l/usr/local/arm/3.3.4/arm-linux/sys-root/usr/lib-- With-sysroot=/usr/local/arm/3.3.4/arm-linux/sys-root
Note:
* Clfalgs and Ldflags values, need to refer to the path of the cross tool chain, my tool is placed in the/usr/local/arm/3.3.4/arm-linux/directory, sysroot path is/usr/local/arm/3.3.4/ Arm-linux/sys-root.
* Specify a good compiler, you also need to develop path, otherwise make, will not find the compiler.

3. Modify some files.
During compilation, some files and tool chains do not match and need to be changed slightly.
1) file Crypto\threads_pthread.c
Line 36:pthread_mutexattr_settype (&attr, pthread_mutex_recursive);
Revision changed to
Pthread_mutexattr_settype (&attr, PTHREAD_MUTEX_RECURSIVE_NP);

Tianjin BU's tool chain comes with the Pthread library header file, and does not directly provide the definition of pthread_mutex_recursive, need a macro __use_unix98, for fast verification of compilation, so direct assignment pthread_mutex_ Recursive_np.
The definition of the attached pthread Library source code:
Enum
{
PTHREAD_MUTEX_TIMED_NP,
PTHREAD_MUTEX_RECURSIVE_NP,
PTHREAD_MUTEX_ERRORCHECK_NP,
Pthread_mutex_adaptive_np
#ifdef __use_unix98
,
Pthread_mutex_normal = PTHREAD_MUTEX_TIMED_NP,
Pthread_mutex_recursive = PTHREAD_MUTEX_RECURSIVE_NP,
Pthread_mutex_errorcheck = PTHREAD_MUTEX_ERRORCHECK_NP,
Pthread_mutex_default = Pthread_mutex_normal
#endif
#ifdef __USE_GNU
/* for compatibility. */
, pthread_mutex_fast_np = pthread_mutex_adaptive_np
#endif
};

2. Modifying the fcntl.h of the tool chain
Useful in OpenSSL to O_text, O_binary, is the SetMode parameter used, is the standard definition of C library, but the toolchain does not provide such a definition declaration. Consult the standard library, which is declared in the Sys/_default_fcntl.h file contained in fcntl.h. The fcntl.h of the cross tool chain does not contain sys/_default_fcntl.h, so it is added manually in Fcntl.h. Add the following code:
#ifndef O_text
#define _fbinary 0x10000
#define _ftext 0x20000
#define _fnoinherit 0x40000
#define _fdirect 0x80000
#define _fnofollow 0x100000
#define _fdirectory 0x200000
#define _fexecsrch 0x400000

#define O_binary _fbinary
#define O_text _ftext
#define O_CLOEXEC _fnoinherit
#define O_direct _fdirect
#define O_nofollow _fnofollow
#define O_dsync _fsync
#define O_rsync _fsync
#define O_directory _fdirectory
#define O_EXEC _fexecsrch
#define O_search _fexecsrch
#endif

At this point, the problem is basically solved, the rest of the things are simple, direct make and make install.
Make installs the generated libraries, tools, and documents into the directory specified by--prefix.

Note:
The 1.make is about the need for the I3-21203.30ghz, my machine is the system of the memory 4gb,win7 64.
2.make installs longer, 2 hours is not finished, mainly installation documentation.


This article is from "Some ideas" blog, be sure to keep this source http://wangyw.blog.51cto.com/4075460/1928514

Cygwin cross-compiling OpenSSL 1.1.0e version

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.