我是关于编码的新手,我遇到了这个问题: 我需要编译一个使用openMP和openSSL的C程序。我使用Homebrew安装openSSL得到这个:
如果您构建自己的软件并且需要此公式,那么您将会这样做 需要添加到您的构建变量:
LDFLAGS: -L/usr/local/opt/openssl/lib CPPFLAGS: -I/usr/local/opt/openssl/include
然后我使用了以下命令
gcc-4.9 -std=c99 -fopenmp main.c -L/usr/local/opt/openssl/lib -lssl
我收到以下错误
Undefined symbols for architecture x86_64: "_CRYPTO_free", referenced from:
_openmp_thread_cleanup in ccESSonD.o "_CRYPTO_malloc", referenced from:
_openmp_thread_setup in ccESSonD.o "_CRYPTO_num_locks", referenced from:
_openmp_thread_setup in ccESSonD.o
_openmp_thread_cleanup in ccESSonD.o "_CRYPTO_set_id_callback", referenced from:
_openmp_thread_setup in ccESSonD.o
_openmp_thread_cleanup in ccESSonD.o "_CRYPTO_set_locking_callback", referenced from:
_openmp_thread_setup in ccESSonD.o
_openmp_thread_cleanup in ccESSonD.o "_ERR_free_strings", referenced from:
_cleanup_EVP in ccESSonD.o "_ERR_load_crypto_strings", referenced from:
_init_EVP in ccESSonD.o "_ERR_print_errors_fp", referenced from:
_handleErrors in ccESSonD.o "_EVP_CIPHER_CTX_cleanup", referenced from:
_getAllRandomness in ccESSonD.o "_EVP_CIPHER_CTX_init", referenced from:
_setupAES in ccESSonD.o "_EVP_EncryptInit_ex", referenced from:
_setupAES in ccESSonD.o "_EVP_EncryptUpdate", referenced from:
_getAllRandomness in ccESSonD.o "_EVP_aes_128_ctr", referenced from:
_setupAES in ccESSonD.o "_EVP_cleanup", referenced from:
_cleanup_EVP in ccESSonD.o "_OPENSSL_add_all_algorithms_noconf", referenced from:
_init_EVP in ccESSonD.o "_OPENSSL_config", referenced from:
_init_EVP in ccESSonD.o "_RAND_bytes", referenced from:
_main in ccESSonD.o "_SHA256_Final", referenced from:
_H in ccESSonD.o
_H3 in ccESSonD.o "_SHA256_Init", referenced from:
_H in ccESSonD.o
_H3 in ccESSonD.o "_SHA256_Update", referenced from:
_H in ccESSonD.o
_H3 in ccESSonD.o ld: symbol(s) not found for architecture x86_64 collect2: error: ld returned 1 exit status
我做错了什么?????
答案 0 :(得分:2)
再次使用-lcrypto选项
答案 1 :(得分:1)
gcc-4.9 -std = c99 -fopenmp main.c -L / usr / local / opt / openssl / lib -lssl
CPPFLAGS
是预处理器的标志。您需要在C中将-I/usr/local/opt/openssl/include
添加到CFLAGS
或在C ++中添加CXXFLAFS
。编译器驱动程序会将适当的标志传递给预处理器。
如果省略-I/usr/local/opt/openssl/include
,那么您将针对OS X的0.9.8标头编译,但链接到Homebrew的1.0.2库。
正如Hanbum所说,你也失踪了-lcrypto
。由于链接器是单次传递,因此顺序对于放置库很重要。
所以编译命令应该是:
gcc-4.9 -I/usr/local/opt/openssl/include -std=c99 -fopenmp main.c \
-L/usr/local/opt/openssl/lib -lssl -lcrypto
我需要编译一个使用openMP和openSSL的C程序。
相关(您的里程可能会有所不同)... OpenMP是获取便携式线程的简便方法。但是,针对Crypto ++(具有OpenMP支持)的基准测试显示,它们减慢了速度,而不是加快速度。
答案 2 :(得分:0)
您需要安装64位版本的库。