Patchwork [10/10] hostapd: fix static build failure

login
register
mail settings
Submitter Samuel Martin
Date Jan. 18, 2014, 7:23 p.m.
Message ID <1390073027-14239-11-git-send-email-s.martin49@gmail.com>
Download mbox | patch
Permalink /patch/312320/
State Superseded
Headers show

Comments

Samuel Martin - Jan. 18, 2014, 7:23 p.m.
When building statically hostapd with openssl support, it is necessary
to add -lz to LIBS to avoid undefined symbols when linking against
libcrypto.a.

Signed-off-by: Samuel Martin <s.martin49@gmail.com>
---
 package/hostapd/hostapd.mk | 1 +
 1 file changed, 1 insertion(+)
Yann E. MORIN - Jan. 18, 2014, 8:05 p.m.
Samuel, All,

On 2014-01-18 20:23 +0100, Samuel Martin spake thusly:
> When building statically hostapd with openssl support, it is necessary
> to add -lz to LIBS to avoid undefined symbols when linking against
> libcrypto.a.
> 
> Signed-off-by: Samuel Martin <s.martin49@gmail.com>

Shouldn't we fix openssl's libcrypto.pc instead?
Adding -lz to Libs.private should do the trick, I guess, no?

Regards,
Yann E. MORIN.
Samuel Martin - Feb. 10, 2014, 11:53 a.m.
On Sat, Jan 18, 2014 at 9:05 PM, Yann E. MORIN <yann.morin.1998@free.fr> wrote:
> Samuel, All,
>
> On 2014-01-18 20:23 +0100, Samuel Martin spake thusly:
>> When building statically hostapd with openssl support, it is necessary
>> to add -lz to LIBS to avoid undefined symbols when linking against
>> libcrypto.a.
>>
>> Signed-off-by: Samuel Martin <s.martin49@gmail.com>
>
> Shouldn't we fix openssl's libcrypto.pc instead?
> Adding -lz to Libs.private should do the trick, I guess, no?
>

Well, both openssl and hostapd use custom build-system (ie.
handwritten configure script and makefiles)...
What a pity! :-(

- on the openssl side:
when building the static library, the libcrypto.pc is wrong because of
what Yann points out (no -lz in Libs.private);

- on the hostapd side:
they just don't care/check about linking against the static library of
libcrypto, they just only add -lcrypto to the ldflags.

So, the right fix would be fixing the *.pc generation in openssl and
call pkg-config to set the cflags and ldflags in hostapd but add a
host-pkgconf dependency.
OTOH, the quickest fix is this patch...

Any input about the preferred way to fix it is welcome.


Regards,

Patch

diff --git a/package/hostapd/hostapd.mk b/package/hostapd/hostapd.mk
index 0fbd8bc..a978094 100644
--- a/package/hostapd/hostapd.mk
+++ b/package/hostapd/hostapd.mk
@@ -32,6 +32,7 @@  endef
 # Try to use openssl if it's already available
 ifeq ($(BR2_PACKAGE_OPENSSL),y)
 	HOSTAPD_DEPENDENCIES += openssl
+	HOSTAPD_LIBS += $(if $(BR2_PREFER_STATIC_LIB),-lcrypto -lz)
 define HOSTAPD_TLS_CONFIG
 	$(SED) 's/\(#\)\(CONFIG_TLS=openssl\)/\2/' $(HOSTAPD_CONFIG)
 	$(SED) 's/\(#\)\(CONFIG_EAP_PWD.*\)/\2/' $(HOSTAPD_CONFIG)