Linked Questions

Popular Questions

Failed to load ibcrypto.so.3 using the Locally compiled OpenSSL

Asked by At

I have the following 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 [email protected]

builds/main: builds/dh.o builds/message.o
builds/main: main.c
    $(CC) $(CFLAGS) -o [email protected] $< builds/dh.o builds/message.o $(LDFLAGS) $(LIBS)

builds/dh.o: dh.h
builds/dh.o: dh.c
    $(CC) $(CFLAGS) -o [email protected] -c $<

builds/message.o: message.h
builds/message.o: message.c
    $(CC) $(CFLAGS) -o [email protected] -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

That sompiles sucessfully my code. But whenb I try to ruin it via these commands:

make clean && make run

The application runs but I get the following error:

./builds/main: error while loading shared libraries: libcrypto.so.3: cannot open shared object file" No such file or directory

I tried to change my Makefile like that:

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 [email protected]

builds/main: builds/dh.o builds/message.o
builds/main: main.c
    $(CC) $(CFLAGS) -o [email protected] $< builds/dh.o builds/message.o $(LDFLAGS) $(LIBS)

builds/dh.o: dh.h
builds/dh.o: dh.c
    $(CC) $(CFLAGS) -o [email protected] -c $<

builds/message.o: message.h
builds/message.o: message.c
    $(CC) $(CFLAGS) -o [email protected] -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

And failed to compile at all:

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

Meaning if compared to the original result is fails to see the library at all whilst on the first error my project is compliled sucessfully but fails to load the dynamic library.

The OpenSSL is loaded via a git submodule as been in this question in order to avoid using a possibly outdated version of it.

So how I can tell in the first case to load the dynamic library or even how I can build the OpenSSL as a static library/(ries)?

Related Questions