haster8558
haster8558

Reputation: 463

Static compilation linking Openssl

I'm tryng to compile a program that links openssl library. When I compile dynamically I get no problems. The problems come up when I add -static flag, i get this error :

gcc  -g -static -static-libgcc -static-libstdc++  -o hmac-sha1-bios-x64 ../main.c -lcrypto -lm
/usr/bin/ld: impossibile trovare -lcrypto
collect2: error: ld returned 1 exit status
Makefile:10: set di istruzioni per l'obiettivo "hmac-sha1-bios-x64" non riuscito
make: *** [hmac-sha1-bios-x64] Errore 1

Has anyone any ideas how to compile statically openssl libraries ?

I looked for some references to libcrypto.a in /usr/lib, but I got only libcrypt.a. I'm working on an archlinux, is it possible the official openssl archlinux package doesn't include the needed files to compiple statically ?

Upvotes: 0

Views: 837

Answers (1)

haster8558
haster8558

Reputation: 463

Ok, I resolved. During the creation of openssl package, all static libs are deleted. The only way is to download the PKGBUILD, then add the "staticlibs" to the options field :

options=('!makeflags' 'staticlibs')

In this way the package is rebuild with static libs and it should work.

Upvotes: 2

Related Questions