Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

configure script fails when doing a static build - libraries passed in wrong place #97

Closed
vincent-olivert-riera opened this issue Feb 25, 2015 · 10 comments

Comments

@vincent-olivert-riera
Copy link

When building libsrtp statically it fails at the configure phase when is testing for EVP_EncryptInit in -lcrypto:

checking whether to leverage OpenSSL crypto... yes
checking for EVP_EncryptInit in -lcrypto... no
configure: error: in '/br/output/build/libsrtp-v1.5.0':
configure: error: can't find openssl >1.0.1 crypto lib
See 'config.log' for more details

The real problem can be found in the config.log:

configure:4831: checking whether to leverage OpenSSL crypto
configure:4840: result: yes
configure:4846: checking for EVP_EncryptInit in -lcrypto
configure:4871: /br/output/host/usr/bin/mipsel-ctng-linux-uclibc-gcc -o conftest -D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 -Os -static -I/br/output/host/usr/mipsel-buildroot-linux-uclibc/sysroot/usr/include -D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 -static -lssl -L/br/output/host/usr/mipsel-buildroot-linux-uclibc/sysroot/usr//lib -lcrypto -lz conftest.c -lcrypto >&5
/br/output/host/usr/mipsel-buildroot-linux-uclibc/sysroot/usr//lib/libcrypto.a(c_zlib.o): In function 'zlib_stateful_expand_block':
c_zlib.c:(.text+0x78): undefined reference to 'inflate'
/br/output/host/usr/mipsel-buildroot-linux-uclibc/sysroot/usr//lib/libcrypto.a(c_zlib.o): In function 'zlib_stateful_compress_block':
c_zlib.c:(.text+0x13c): undefined reference to 'deflate'
[...]
collect2: error: ld returned 1 exit status

There is a missing -lz after conftest.c. Also, the -lcrypto -lz before conftest.c are useless. So, a command like this one would fix the problem:

/br/output/host/usr/bin/mipsel-ctng-linux-uclibc-gcc -o conftest -D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 -Os -static -I/br/output/host/usr/mipsel-buildroot-linux-uclibc/sysroot/usr/include -D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 -static -lssl -L/br/output/host/usr/mipsel-buildroot-linux-uclibc/sysroot/usr//lib conftest.c -lcrypto -lz

@jfigus
Copy link
Contributor

jfigus commented Feb 26, 2015

What ./configure arguments are you using to build libsrtp statically? When setting CFLAGS=-static, I see a link error due to -ldl, not -lz. Maybe you've compiled OpenSSL differently.

@vincent-olivert-riera
Copy link
Author

Hello jfigus,

I don't know if that rellevant. Anyway, could you please have a look to this patch? One of the Buildroot developers wrote it.

http://lists.busybox.net/pipermail/buildroot/2015-February/120140.html

It uses PKG_CHECK_MODULES instead of AC_CHECK_LIB in order to fix the problem.

Is that patch upstreamable?

@jfigus
Copy link
Contributor

jfigus commented Feb 26, 2015

PKG_CHECK_MODULES is from pkg-config, not autoconf. We could classify this issue as a feature request to include support for pkg-config. I don't see this as a bug fix. Also, the patch doesn't ensure the appropriate revision level of OpenSSL is on the system. It only checks for the presence of any revision of OpenSSL. If OpenSSL 0.9.8 was on the system, then the libsrtp compiliation would fail.

@vincent-olivert-riera
Copy link
Author

Well, that patch was for Buildroot and our openssl version is 1.0.2.

Ok, I see your point. Then, here you have the information you requested:

./configure --target=powerpc-buildroot-linux-uclibc --host=powerpc-buildroot-linux-uclibc --build=x86_64-unknown-linux-gnu --prefix=/usr --exec-prefix=/usr --sysconfdir=/etc --localstatedir=/var --program-prefix="" --disable-dependency-tracking --enable-static --disable-shared --with-tools=no

If you want to see the full build log, is here:

http://autobuild.buildroot.net/results/a71/a71d85a5bb9af2ee82a8e61054025bceb03dbdeb/build-end.log

@jfigus
Copy link
Contributor

jfigus commented Feb 26, 2015

b5fad5f adds checks for libz and libdl to allow static linking of libcrypto.a. I wasn't able to duplicate the libz issue on my system, but added this anyway since it appears your OpenSSL is likely configured different. By the way, libsrtp doesn't recognize the --enable-static and --disable-shared options. Your build log includes "CFLAGS=-static", which is how you're enabling the static link.

@vincent-olivert-riera
Copy link
Author

Hello jfigus,

I have tested your patch and I can confirm it fixes the problem. Thank you very much.

@jfigus
Copy link
Contributor

jfigus commented Feb 26, 2015

Glad to help. I've used buildroot several times in the past. It's a very useful project. +1 for buildroot.

@RomainNaour
Copy link

Hi jfigus,

Thank you for your help.
In Buildroot, openssl is always build with zlib support, that is why we need to have -lz flag for linking with libcrypto.a.
But it's an optional dependency since zlib support can be disabled:
See Configure script in openssl:
"[no-]zlib [don't] compile support for zlib compression"
So, it's not correct to error out when zlib is not necessary for linking with libcrypto.a.

It's the same for libdl.
See this build failure that happened after your patch has been applied in Buildroot.
http://autobuild.buildroot.net/results/a77/a770318af841610e0c10f61cf61bdae298aa59a8/build-end.log

It's not the same toolchain used in this case, this is a Blackfin toolchain which doesn't support shared libraries.

I suggest to remove AC_MSG_FAILURE if libdl or zlib is not detected.
libsrtp build fine without libdl in this specific case.

Thanks.

@jfigus
Copy link
Contributor

jfigus commented Mar 2, 2015

OK, I've changed the libz and libdl checks to warnings when not found.

@Globik
Copy link

Globik commented Feb 1, 2016

But keeps complaining that libdl not found.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants