【发布时间】:2019-02-05 21:30:56
【问题描述】:
我有一个 C 项目,带有以下 Makefile:
CC=mpicc
buildsDir: ./builds
mkdir ./builds
main: ./builds message dh main.c
$(CC) -o ./builds/main main.c ./builds/dh.o ./builds/message.o -g -lcrypto -lssl
dh: ./builds dh.c dh.h
$(CC) -c -o ./builds/dh.o dh.c -g -lcrypto -lssl
message: message.c message.h
$(CC) -c -o ./builds/message.o -g ./message.c
run: main
mpirun -quiet -np 3 xterm -hold -e ./builds/main &
debug: main
mpirun -quiet -np 3 xterm -e gdb ./builds/main
.PHONY: clean
clean:
rm -rf ./builds && mkdir ./builds
在我的系统中,我有 OpenSSL 1.0.2g:
OpenSSL 1.0.2g 1 Mar 2016
built on: reproducible build, date unspecified
platform: debian-amd64
options: bn(64,64) rc4(16x,int) des(idx,cisc,16,int) blowfish(idx)
compiler: cc -I. -I.. -I../include -fPIC -DOPENSSL_PIC -DOPENSSL_THREADS -D_REENTRANT -DDSO_DLFCN -DHAVE_DLFCN_H -m64 -DL_ENDIAN -g -O2 -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -Wl,-Bsymbolic-functions -Wl,-z,relro -Wa,--noexecstack -Wall -DMD32_REG_T=int -DOPENSSL_IA32_SSE2 -DOPENSSL_BN_ASM_MONT -DOPENSSL_BN_ASM_MONT5 -DOPENSSL_BN_ASM_GF2m -DSHA1_ASM -DSHA256_ASM -DSHA512_ASM -DMD5_ASM -DAES_ASM -DVPAES_ASM -DBSAES_ASM -DWHIRLPOOL_ASM -DGHASH_ASM -DECP_NISTZ256_ASM
OPENSSLDIR: "/usr/lib/ssl"
但是在我的原型软件上,由于缺少系统提供的版本,我需要它的更高版本,并且我想避免在全球范围内安装它。因此,我想使用仅限本地版本的专业项目范围。我发现 these 说明为我提供了一个很棒的框架。
我还做了第一步添加是作为我项目的子模块:
[submodule "openssl"]
path = openssl
url = https://github.com/openssl/openssl.git
branch = OPENSSL_1_1_1a
在控制台上,我尝试使用以下命令集手动构建它:
cd openssl
./config --prefix=$(pwd)/../builds/openssl --openssldir=$(pwd)/../builds/openssl
make && make test && make install
现在我想更进一步,以某种方式致电mpicc 以链接位于builds 目录的构建openssl lib,但我不知道。
【问题讨论】:
标签: c makefile openssl gnu-make