无法使用本地编译OpenSSL的加载ibcrypto.so.3

问题描述 投票:1回答:1

我有以下Makefile

CC=mpicc

# use headers from builds/openssl
CFLAGS := -g -I${CURDIR}builds/openssl/include/openssl

# look for library in builds/openssl
LDFLAGS := -L${CURDIR}builds/openssl/lib
LIBS    := -lcrypto -lssl

.PHONY: all
all: builds/main

builds:
    mkdir -p $@

builds/main: builds/dh.o builds/message.o
builds/main: main.c
    $(CC) $(CFLAGS) -o $@ $< builds/dh.o builds/message.o $(LDFLAGS) $(LIBS)

builds/dh.o: dh.h
builds/dh.o: dh.c
    $(CC) $(CFLAGS) -o $@ -c $<

builds/message.o: message.h
builds/message.o: message.c
    $(CC) $(CFLAGS) -o $@ -c $<

builds/dh.o builds/message.o builds/main: builds

# if you want to build openssl with your makefile...
builds/dh.o builds/message.o builds/main: builds/openssl
builds/openssl: builds
    cd openssl && ./config --prefix=${CURDIR}/builds/openssl --openssldir=${CURDIR}/builds/openssl && make && make test && make install

.PHONY: run

run: builds/main
    mpirun -quiet -np 3 xterm -hold -e ./builds/main &

.PHONY: debug

debug: builds/main
    mpirun -quiet -np 3 xterm -e gdb ./builds/main

.PHONY: clean

clean:
    rm -rf ./builds

这编译成功我的代码。但是,当我试图通过这些命令毁掉它:

make clean && make run

该应用程序运行,但我得到以下错误:

./builds/main:错误而载入共享库:libcrypto.so.3:无法打开共享对象文件”没有这样的文件或目录

我试图改变我的Makefile这样的:

CC=mpicc

# use headers from builds/openssl
CFLAGS := -g -I${CURDIR}builds/openssl/include/openssl

# look for library in builds/openssl
LDFLAGS := -L${CURDIR}builds/openssl/lib
LIBS    := -lcrypto -lssl

.PHONY: all
all: builds/main

builds:
    mkdir -p $@

builds/main: builds/dh.o builds/message.o
builds/main: main.c
    $(CC) $(CFLAGS) -o $@ $< builds/dh.o builds/message.o $(LDFLAGS) $(LIBS)

builds/dh.o: dh.h
builds/dh.o: dh.c
    $(CC) $(CFLAGS) -o $@ -c $<

builds/message.o: message.h
builds/message.o: message.c
    $(CC) $(CFLAGS) -o $@ -c $<

builds/dh.o builds/message.o builds/main: builds

# if you want to build openssl with your makefile...
builds/dh.o builds/message.o builds/main: builds/openssl
builds/openssl: builds
    cd openssl && ./config --prefix=${CURDIR}/builds/openssl --openssldir=${CURDIR}/builds/openssl && make && make test && make install

.PHONY: run

run: builds/main
    mpirun -quiet -np 3 xterm -hold -e ./builds/main &

.PHONY: debug

debug: builds/main
    mpirun -quiet -np 3 xterm -e gdb ./builds/main

.PHONY: clean

clean:
    rm -rf ./builds

并未能在所有的编译:

main.c: In function ‘main’:
main.c:76:10: warning: implicit declaration of function ‘DH_get0_pub_key’ [-Wimplicit-function-declaration]
   pubKey=DH_get0_pub_key(secret);
          ^
main.c:76:9: warning: assignment makes pointer from integer without a cast [-Wint-conversion]
   pubKey=DH_get0_pub_key(secret);
         ^
main.c:125:5: warning: implicit declaration of function ‘DH_get0_p’ [-Wimplicit-function-declaration]
   p=DH_get0_p(secret);
     ^
main.c:125:4: warning: assignment makes pointer from integer without a cast [-Wint-conversion]
   p=DH_get0_p(secret);
    ^
/tmp/ccgccndI.o: In function `main':
/home/pcmagas/Kwdikas/master_thesis/mpi_dh/main.c:76: undefined reference to `DH_get0_pub_key'
/home/pcmagas/Kwdikas/master_thesis/mpi_dh/main.c:125: undefined reference to `DH_get0_p'
builds/dh.o: In function `generateKeys':
/home/pcmagas/Kwdikas/master_thesis/mpi_dh/dh.c:20: undefined reference to `DH_set0_pqg'
builds/dh.o: In function `generateKeyFromPreviousParticipant':
/home/pcmagas/Kwdikas/master_thesis/mpi_dh/dh.c:136: undefined reference to `DH_get0_priv_key'
/home/pcmagas/Kwdikas/master_thesis/mpi_dh/dh.c:147: undefined reference to `DH_get0_p'
collect2: error: ld returned 1 exit status
Makefile:18: recipe for target 'builds/main' failed

这意味着如果比原来的结果没有看到图书馆在所有同时在第一个错误我的项目是成功地compliled但无法加载动态库。

OpenSSL的是通过为已经在该question为了避免使用它的可能是过时的版本,一个git子模块加载。

所以,我怎么能在第一种情况告诉加载动态库或者我连怎么能建立在OpenSSL作为静态库/(里斯)?

c openssl mpi linker-errors dynamic-linking
1个回答
0
投票

它不会出现你已经添加了动态库到您的可执行文件运行时搜索路径。看一看在-rpath链接标志。最有可能的,你需要像-Wl,-rpath,${CURDIR}/builds/openssl/lib添加到您的链接标志。

© www.soinside.com 2019 - 2024. All rights reserved.