4

I'm trying to install openssl in cygwin by following these instructions: I dowloaded the latest tarball from this site http://www.openssl.org/source/, and put it in C:\cygwin64\home, then I run these commands from cygwin

  1. tar zxvf openssl-1.0.1e.tar.gz
  2. cd openssl-1.0.1e
  3. ./config
  4. make
  5. make test
  6. make install

    (Instructions from here :http://www.slideshare.net/ganaaturuu/cygwinandopen-sslinstallguide)

Up to the 3rd step ./config it works fine I believe, at least there are no errors reported, and it gives the message "Configured for Cygwin." in the end. When I run make though it gives me this output:

making all in crypto...
make[1]: Entering directory '/home/openssl-1.0.1e/crypto'
( echo "#ifndef MK1MF_BUILD"; \
echo '  /* auto-generated by crypto/Makefile for crypto/cversion.c */'; \
echo '  #define CFLAGS "gcc -DOPENSSL_THREADS  -DDSO_DLFCN -DHAVE_DLFCN_H -DTERM                                                                                                                IOS -DL_ENDIAN -fomit-frame-pointer -O3 -march=i486 -Wall -DOPENSSL_BN_ASM_PART_                                                                                                                WORDS -DOPENSSL_IA32_SSE2 -DOPENSSL_BN_ASM_MONT -DOPENSSL_BN_ASM_GF2m -DSHA1_ASM                                                                                                                 -DSHA256_ASM -DSHA512_ASM -DMD5_ASM -DRMD160_ASM -DAES_ASM -DVPAES_ASM -DWHIRLP                                                                                                                OOL_ASM -DGHASH_ASM"'; \
echo '  #define PLATFORM "Cygwin"'; \
echo "  #define DATE \"`LC_ALL=C LC_TIME=C date`\""; \
echo '#endif' ) >buildinf.h
gcc -I. -I.. -I../include  -DOPENSSL_THREADS  -DDSO_DLFCN -DHAVE_DLFCN_H -DTERMI                                                                                                                OS -DL_ENDIAN -fomit-frame-pointer -O3 -march=i486 -Wall -DOPENSSL_BN_ASM_PART_W                                                                                                                ORDS -DOPENSSL_IA32_SSE2 -DOPENSSL_BN_ASM_MONT -DOPENSSL_BN_ASM_GF2m -DSHA1_ASM                                                                                                                 -DSHA256_ASM -DSHA512_ASM -DMD5_ASM -DRMD160_ASM -DAES_ASM -DVPAES_ASM -DWHIRLPO                                                                                                                OL_ASM -DGHASH_ASM   -c -o cryptlib.o cryptlib.c
cryptlib.c:1:0: error: CPU you selected does not support x86-64 instruction set
 /* crypto/cryptlib.c */
 ^
cryptlib.c:1:0: error: CPU you selected does not support x86-64 instruction set
<builtin>: recipe for target 'cryptlib.o' failed
make[1]: *** [cryptlib.o] Error 1
make[1]: Leaving directory '/home/openssl-1.0.1e/crypto'
Makefile:278: recipe for target 'build_crypto' failed
make: *** [build_crypto] Error 1

I searched about the "CPU you selected does not support x86-64 instruction set" and I think it has to do with CFLAGS and -march=i486 option, but I'm not at all sure as into what it should be changed.

In this How to compile a C++ program as 64-bit on 64-bit machine? question there are some solutions suggested, but in my case there are nowhere in the makefile options like -m32 and -march=i686 to remove.

If you could please show me the right direction to search this, if not the solution, I would be grateful.

I'm working on Windows 7 64-bit, with cygwin and gcc version 4.8.2.

Community
  • 1
  • 1
PetMarion
  • 147
  • 3
  • 14

3 Answers3

6

Here's a "mee too" answer because things have changed a bit. Cygwin-x64 support was cut-in in May 2015 under Issue 3110: Adding support for x86_64 Cygwin.

However, config still selects the i686 version of the library to build. Also see Issue #4326: Failed to configure for Cygwin-x64 in the OpenSSL bug tracker.

To build OpenSSL 1.0.2 on Cygwin-x64, you have to use Configure and select the triplet. Below is the soup-to-nuts recipe.

$ curl https://www.openssl.org/source/openssl-1.0.2f.tar.gz -o openssl-1.0.2f.tar.gz
...
$ tar -xzf openssl-1.0.2f.tar.gz
...
$ cd openssl-1.0.2f

Then:

$ ./Configure Cygwin-x86_64 shared no-ssl2 no-ssl3 --openssldir="$HOME/ssl"
...
$ make depend
...
$ make
...
$ make install_sw

install_sw installs the headers in $OPENSSLDIR/include, and the libraries in $OPENSSLDIR/lib. It does not install the man pages.

You then compile and link with:

$ gcc -I "$HOME/ssl/include" test.c -o test.exe "$HOME/ssl/lib/libcrypto.a" "$HOME/ssl/lib/libssl.a"

Linking against libcrypto.a and libssl.a means you avoid library path problems. Things will "just work" for you.


Also, if you need this for OpenSSL 1.0.1, then you can copy/paste the triplet's settings from 1.0.2's Configure (from line 613):

$ grep "Cygwin-x86_64" Configure
"Cygwin-x86_64", "gcc:-DTERMIOS -DL_ENDIAN -O3 -Wall:::CYGWIN::SIXTY_FOUR_BIT_LONG RC4_CHUNK DES_INT DES_UNROLL:${x86_64_asm}:mingw64:dlfcn:cygwin-shared:-D_WINDLL:-shared:.dll.a",

If you want config to "just work" for 1.0.1, then add the following. Be sure the line for Cygwin-x86_64 was added to Configure.

x86_64-*-cygwin) OUT="Cygwin-x86_64" ;;     <== Add this in front of the ones below
*-*-cygwin_pre1.3) OUT="Cygwin-pre1.3" ;;
*-*-cygwin) OUT="Cygwin" ;;
jww
  • 97,681
  • 90
  • 411
  • 885
  • Thanks a lot. I tried a lot of solutions during a lot of hours, this was the only working solution for me. It was to be able to `rvm install 2.2.6` (a very old version). After trying and merging some found solutions I end up with, after I followed the above except the final `gcc` I think, and using `--openssldir="$HOME/.rvm/src/ssl"` for `./Configure` and `rvm install 2.2.6 --with-openssl-dir=/home/Per/.rvm/src/ssl`, and had to do this while that was running (before the `installing` step): `sed -i.bak 's/dlload *"kernel32"/dlload "kernel32.dll"/'` for files that includes `dlload "kernel32"` – 244an Mar 26 '20 at 14:08
0

It would seem that 1.0.1 does not have support for Cygwin/x64.

This thread indicates that the necessary patches have been pulled into the 1.0.2 branch.

Joachim Isaksson
  • 176,943
  • 25
  • 281
  • 294
  • In the meantime, a patched version has been available in the Cygwin distro since the debut of x64. – Yaakov Dec 29 '13 at 20:04
  • 1
    It appears OpenSSL 1.0.2 also lacks the support. Now open on the OpenSSL bug tracker: [Issue #4326: Failed to configure for Cygwin-x64](http://rt.openssl.org/Ticket/Display.html?id=4326) – jww Feb 21 '16 at 00:43
  • Note that in order to see the ticket you have to either log in using "guest" for both name and passwort or you use the following link which contains the login information in the URL: https://rt.openssl.org/Ticket/Display.html?user=guest&pass=guest&id=4326 – Alex Mar 04 '16 at 09:00
0

here is one post you can refer to. the basic idea is that specifying -march=x86-64 and avoid using assembly language. assembly language is not as portable as c language.