我正试图按照以下说明在cygwin中安装openssl:我从这个网站下载了最新的tarballhttp://www.openssl.org/source/,并将其放在C:\cygwin64\home中,然后我从cygwin 运行这些命令
- tar zxvf openssl-1.0.1e.tar.gz
- cd openssl-1.0.1e
- /配置
- 制造
- 进行测试
-
制作安装
(此处的说明:http://www.slideshare.net/ganaaturuu/cygwinandopen-sslinstallguide)
直到第三步/config,我相信它工作得很好,至少没有错误报告,最后它给出了"为Cygwin配置"的消息。当我运行make时,它会给我这个输出:
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
我搜索了"您选择的CPU不支持x86-64指令集",我认为这与CFLAGS和-march=i486选项有关,但我完全不确定应该更改什么。
如何在64位机器上将C++程序编译为64位?问题是,建议了一些解决方案,但在我的情况下,makefile选项中没有任何地方可以删除,比如-m32和-march=i686。
如果你能告诉我搜索这个的正确方向,如果不是解决方案,我将不胜感激。
我使用的是Windows7 64位,cygwin和gcc版本4.8.2。
这里有一个"mee-too"的答案,因为事情发生了一些变化。Cygwin-x64支持在2015年5月的第3110期中被删除:添加对x86_64 Cygwin的支持。
但是,config
仍然选择要构建的库的i686版本。另请参阅问题#4326:在OpenSSL错误跟踪器中配置Cygwin-x64失败。
要在Cygwin-x64上构建OpenSSL 1.0.2,您必须使用Configure
并选择三元组。下面是坚果汤的配方。
$ 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
然后:
$ ./Configure Cygwin-x86_64 shared no-ssl2 no-ssl3 --openssldir="$HOME/ssl"
...
$ make depend
...
$ make
...
$ make install_sw
install_sw
在$OPENSSLDIR/include
中安装头,在$OPENSSLDIR/lib
中安装库。它不安装手册页。
然后编译并链接到:
$ gcc -I "$HOME/ssl/include" test.c -o test.exe "$HOME/ssl/lib/libcrypto.a" "$HOME/ssl/lib/libssl.a"
针对libcrypto.a
和libssl.a
进行链接意味着您可以避免库路径问题。事情会对你"起作用"。
此外,如果OpenSSL 1.0.1需要此功能,则可以从1.0.2的Configure
复制/粘贴三元组的设置(来自第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",
如果您希望config
在1.0.1中"正常工作",请添加以下内容。请确保Cygwin-x86_64
的行已添加到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" ;;
1.0.1似乎不支持Cygwin/x64。
该线程表示已将必要的补丁拉入1.0.2分支。
这里有一篇你可以参考的文章。基本思想是指定-march=x86-64并避免使用汇编语言。汇编语言不如c语言可移植。