OpenWrt Forum Archive

Topic: problem compiling OpenSSL on current trunk - AR71xx

The content of this topic has been archived on 23 Apr 2018. There are no obvious gaps in this topic, but there may still be some posts missing at the end.

i have download a fresh trunk copy of OpenWRT but i'm not being able to compile it for AR71xx target. Seems problem is compiling OpenSSL.

make[5]: Entering directory `/home/solutti/openwrt2/trunk/build_dir/target-mips_uClibc-0.9.29/openssl-0.9.8i/apps'
rm -f openssl
shlib_target=; if [ -n "libcrypto.so.0.9.8 libssl.so.0.9.8" ]; then \
                shlib_target="linux-shared"; \
        fi; \
        LIBRARIES="-L.. -lssl  -L.. -lcrypto" ; \
        make -f ../Makefile.shared -e \
                APPNAME=openssl OBJECTS="openssl.o verify.o asn1pars.o req.o dgst.o dh.o dhparam.o enc.o passwd.o gendh.o errstr.o ca.o pkcs7.o crl2p7.o crl.o rsa.o rsautl.o dsa.o dsaparam.o ec.o ecparam.o x509.o genrsa.o gendsa.o s_server.o s_client.o speed.o s_time.o apps.o s_cb.o s_socket.o app_rand.o version.o sess_id.o ciphers.o nseq.o pkcs12.o pkcs8.o spkac.o smime.o rand.o engine.o ocsp.o prime.o cms.o" \
                LIBDEPS=" $LIBRARIES -L/home/solutti/openwrt2/trunk/staging_dir/toolchain-mips_gcc-4.2.4_uClibc-0.9.29/usr/lib -L/home/solutti/openwrt2/trunk/staging_dir/toolchain-mips_gcc-4.2.4_uClibc-0.9.29/lib -L/home/solutti/openwrt2/trunk/staging_dir/target-mips_uClibc-0.9.29/usr/lib -L/home/solutti/openwrt2/trunk/staging_dir/target-mips_uClibc-0.9.29/lib -ldl -ldl" \
                link_app.${shlib_target}
make[6]: Entering directory `/home/solutti/openwrt2/trunk/build_dir/target-mips_uClibc-0.9.29/openssl-0.9.8i/apps'
/home/solutti/openwrt2/trunk/staging_dir/toolchain-mips_gcc-4.2.4_uClibc-0.9.29/usr/lib/gcc/mips-openwrt-linux-uclibc/4.2.4/../../../../mips-openwrt-linux-uclibc/bin/ld: error while loading shared libraries: /home/solutti/openwrt2/trunk/staging_dir/target-mips_uClibc-0.9.29/usr/lib/libz.so.1: ELF file data encoding not little-endian
collect2: ld returned 127 exit status
make[6]: *** [link_app.gnu] Error 1
make[6]: Leaving directory `/home/solutti/openwrt2/trunk/build_dir/target-mips_uClibc-0.9.29/openssl-0.9.8i/apps'
make[5]: *** [openssl] Error 2

problem seems to be:

make[6]: Entering directory `/home/solutti/openwrt2/trunk/build_dir/target-mips_uClibc-0.9.29/openssl-0.9.8i/apps'
/home/solutti/openwrt2/trunk/staging_dir/toolchain-mips_gcc-4.2.4_uClibc-0.9.29/usr/lib/gcc/mips-openwrt-linux-uclibc/4.2.4/../../../../mips-openwrt-linux-uclibc/bin/ld: error while loading shared libraries: /home/solutti/openwrt2/trunk/staging_dir/target-mips_uClibc-0.9.29/usr/lib/libz.so.1: ELF file data encoding not little-endian
collect2: ld returned 127 exit status




i dont have a clue how to solve this ........

i was previously using a trunk for about 1 month ago, which already uses openssl 0.9.8i, and could compile it successfully.

(Last edited by leonardogyn on 19 Jan 2009, 03:33)

following the recommendation from another post, i successfully compiled trunk by moving out the offending library to another place and running make again.

mv  /home/solutti/openwrt2/trunk/staging_dir/target-mips_uClibc-0.9.29/usr/lib/libz.so.1   /tmp
make V=99
CTRL+C right after OpenSSL compilation finishes
mv    /tmp/libz.so.1   /home/solutti/openwrt2/trunk/staging_dir/target-mips_uClibc-0.9.29/usr/lib/libz.so.1
make V=99    (again, which is still running big_smile)

Works for me with revision 14103. Builded on a Debian stable x86_64 box...

i did a svn checkout this morning and i can see some openssl related updates.

[solutti@f8 openwrt2]$ svn checkout https://svn.openwrt.org/openwrt/trunk/ 
U    trunk/target/linux/ixp4xx/image/Makefile
A    trunk/target/linux/ixp4xx/image/apex/patches/160-openwrt_nas100d_armeb_config.patch
U    trunk/target/linux/ixp4xx/image/apex/Makefile
A    trunk/package/openssl/patches/100-parallel-build.patch
U    trunk/package/openssl/patches/140-makefile-dirs.patch
U    trunk/package/openssl/patches/160-disable_doc_tests.patch
U    trunk/package/openssl/Makefile
Checked out revision 14104.
[solutti@f8 openwrt2]$

its building openssl 0.9.8j instead of 0.9.8i

still no success on compiling ......

i excluded full trunk tree and started a fresh one, trying to eliminate some garbage from last buildings that could be messing with the actual build ...... but no success. Error is pretty similar:

make[6]: Entering directory `/home/solutti/openwrt2/trunk/build_dir/target-mips_uClibc-0.9.29/openssl-0.9.8j'
/home/solutti/openwrt2/trunk/staging_dir/toolchain-mips_gcc-4.2.4_uClibc-0.9.29/usr/lib/gcc/mips-openwrt-linux-uclibc/4.2.4/../../../../mips-openwrt-linux-uclibc/bin/ld: error while loading shared libraries: /home/solutti/openwrt2/trunk/staging_dir/target-mips_uClibc-0.9.29/usr/lib/libz.so.1: ELF file data encoding not little-endian
collect2: ld returned 127 exit status
make[6]: *** [link_a.gnu] Error 1


this is a Fedora 8 x86 box ...

as i told on the previous posts, i could successfully build trunk some revisions ago, dont know exactly which ones, 1 month ago i'm pretty sure.

nobody could reproduce this error ???

is everybody getting good builds on current revisions ???

Same problem at me too.

Previously I have ran into this problem:

https://dev.openwrt.org/ticket/4480#comment:2

I did the following:
make package/openssl-{clean,compile}

Since then I am still stucking at the same problem as yours.

The target is BCM63xx (big endian)
The trunk revision: 14131
I am doing this on my x86 ubuntu box.

Five days ago I have successfully compliled the trunk too.

i posted on the ticket saying i'm also facing the problem and couldnt solve it with clean/compile .........

i tried to reopen it, but it says i dont have permission.

I just did a fresh build of ar71xx with svn 14139 and had no issue.  I am on Ubuntu 8.10 x86_64.  I have run into many issues with not getting make to reset things.  I suggest:  1) do a fresh svn checkout into an empty new directory, it isn't that large.  2) copy over your trunk/dl files from old and new tree to save bandwidth re-downloading things.  3) Do a make on your clean install.

When frustrated with not getting make clean/compile and all that to work - this always solves my issues wink

(Last edited by RoundSparrow on 21 Jan 2009, 22:29)

It seems I am experiencing the same problem with latest trunk builds. I did a fresh checkout today and built under Ubuntu 8.10-32bit, target x86 (Alix) and I got errors regarding OpenSSL.

i486-openwrt-linux-uclibc-ar: creating ../libssl.a
i486-openwrt-linux-uclibc-ranlib ../libssl.a || echo Never mind.
make[5]: Leaving directory `/home/user/alix/build_dir/target-i386_uClibc-0.9.29/openssl-0.9.8j/ssl'
make[5]: Entering directory `/home/user/alix/build_dir/target-i386_uClibc-0.9.29/openssl-0.9.8j'
make[6]: Entering directory `/home/user/alix/build_dir/target-i386_uClibc-0.9.29/openssl-0.9.8j'
i486-openwrt-linux-uclibc-gcc: /home/user/alix/staging_dir/toolchain-i386_gcc-4.1.2_uClibc-0.9.29/lib/libpthread.so.0: no version information available (required by /usr/lib/libv4l1.so.0)
i486-openwrt-linux-uclibc-gcc: /home/user/alix/staging_dir/toolchain-i386_gcc-4.1.2_uClibc-0.9.29/lib/libpthread.so.0: no version information available (required by /usr/lib/libv4l2.so.0)
Segmentation fault
make[6]: *** [link_a.gnu] Error 139
make[6]: Leaving directory `/home/user/alix/build_dir/target-i386_uClibc-0.9.29/openssl-0.9.8j'
make[5]: *** [do_linux-shared] Error 2
make[5]: Leaving directory `/home/user/alix/build_dir/target-i386_uClibc-0.9.29/openssl-0.9.8j'
make[4]: *** [libcrypto.so.0.9.8] Error 2
make[4]: Leaving directory `/home/user/alix/build_dir/target-i386_uClibc-0.9.29/openssl-0.9.8j'
make[3]: *** [/home/user/alix/build_dir/target-i386_uClibc-0.9.29/openssl-0.9.8j/.built] Error 2
make[3]: Leaving directory `/home/user/alix/package/openssl'
make[2]: *** [package/openssl/compile] Error 2
make[2]: Leaving directory `/home/user/alix'
make[1]: *** [/home/user/alix/staging_dir/target-i386_uClibc-0.9.29/stamp/.package_compile] Error 2
make[1]: Leaving directory `/home/user/alix'
make: *** [world] Fehler 2

I successfully built from trunk a few days ago, where OpenSSL 0.9.8i was used.

it seems i have found what was happening here on my builds ......

i'm one of what we can call 'new version maniac' ..... i always think that in terms of software version, 'the newer, the better'.

so, in my build, i had choosen newest binutils (2.19), gcc (4.3.2) and uclibc (0.9.30). and build failed as i reported.

playing with different configurations, i finally concluded that binutils 2.19 was the bad guy.

tests were made with revision 14144 (i know, 1-2 days ago) ... but i didnt update to use the very same revision between all tests i have made. Anyway i revised changesets after 14144 and seems nothing was changed to OpenSSL/binutils, so probably the problem would persist.

steps i made to conclude that:

1) i erased my .config and started from a fresh one
2) enabled broken plataforms and select AR71xx target
3) choose gcc 4.3.2
4) choose uclibc 0.9.30
5) choose binutils 2.17
6) exclude some packages to make build faster (kmod-madwifi, hostapp, dropbear, dnsmasq) and choose openssl-utils (which selects libopenssl) to make sure OpenSSL would be built

compile OK

completely excluded staging_dir, build_dir and bin directories to force a complete rebuild of packages and toolchain

make menuconfig    and choose binutils 2.18, everything else wasnt changed.

compile OK

completely excluded staging_dir, build_dir and bin directories

make menuconfig    and choose binutils 2.19

build fails with the exact error i posted some days ago:

make[6]: Entering directory `/home/solutti/openwrt2/trunk/build_dir/target-mips_uClibc-0.9.30/openssl-0.9.8j'
/home/solutti/openwrt2/trunk/staging_dir/toolchain-mips_gcc-4.3.2_uClibc-0.9.30/usr/lib/gcc/mips-openwrt-linux-uclibc/4.3.2/../../../../mips-openwrt-linux-uclibc/bin/ld: error while loading shared libraries: /home/solutti/openwrt2/trunk/staging_dir/target-mips_uClibc-0.9.30/usr/lib/libz.so.1: ELF file data encoding not little-endian
collect2: ld returned 127 exit status
make[6]: *** [link_a.gnu] Error 1


i have the full log from the build with the 3 versions of binutils (and always gcc 4.3.2 and uclibc 0.9.30), in the case some developer wants that ... 1Mb the 3 logs bziped, 15Mb each one uncompressed smile

and finally, i got back my full .config, changed binutils to 2.18 and finally i got a good build, with no compile failures, and openssl being correctly build.

my case is problem different than fireand one, because its logs shows he's using uclibc 0.9.29 and gcc 4.1.2 ..... which make me concludes that he probably didnt changed software versions and, thus, is using binutils 2.17 which is the default .... and at least i could get good build with 2.17.

but the fact is that people seems to really having problems building OpenSSL in different situations on newest trunks.

i have done a svn checkout today:

[solutti@f8 openwrt]$ svn checkout https://svn.openwrt.org/openwrt/trunk/     
Checked out revision 14190.
[solutti@f8 openwrt]$


the situation i explained on my last message:

successfull built with

glibc 4.3.2
uclibc 0.9.30
binutils 2.18

built NOT OK with

glibc 4.3.2
uclibc 0.9.30
binutils 2.19


is still present.

failure is still on OpenSSL with the very same error i post on my last message.


make[5]: Entering directory `/home/solutti/openwrt2/trunk/build_dir/target-mips_uClibc-0.9.30/openssl-0.9.8j'
make[6]: Entering directory `/home/solutti/openwrt2/trunk/build_dir/target-mips_uClibc-0.9.30/openssl-0.9.8j'
/home/solutti/openwrt2/trunk/staging_dir/toolchain-mips_gcc-4.3.2_uClibc-0.9.30/usr/lib/gcc/mips-openwrt-linux-uclibc/4.3.2/../../../../mips-openwrt-linux-uclibc/bin/ld: error while loading shared libraries: /home/solutti/openwrt2/trunk/staging_dir/target-mips_uClibc-0.9.30/usr/lib/libz.so.1: ELF file data encoding not little-endian
collect2: ld returned 127 exit status
make[6]: *** [link_a.gnu] Error 1

I realize this is an old thread, but it came up in a google search today as I was trying to compile a clean 8.09.1 build.
My colleague provided recipe steps to build kamikaze 8.09.1 that failed for me with a similar error, only the referenced
library was different, in my case the offending library was libpthread, a fairly standard piece of the gcc toolchain.

My perusal of this thread suggested the following information may be useful to other folks.

The basic problem usually occurs in a cross-development environment, especially when the endianess of the host and target differ.
The runtime linker (man ld.so) needs to be able to find the host version of dynamically loaded libraries (think dll files in the land of Microsoft).
Most big Linux binaries are dynamically linked, which implies the runtime linker has to be able to find the correct version of the required libraries.

To confirm my suspicions, I typed this command:  echo $LD_LIBRARY_PATH

The output was: ../lib

The environment variable LD_LIBRARY_PATH is similar to PATH, only it is used by the runtime linker to find library files.
The above setting overrode the default setting which caused the error regarding the wrong endinanness of the pthread library file.

When trying to setup/install the cross-development toolchain to build ARM big-endian binaries on an x86 little-endian machine, the
wrong libraries were being referenced at runtime.

My workaround was to guarantee a benign setting for the LD_LIBRARY_PATH environment variable, with this bash command:

export LD_LIBRARY_PATH=/lib:/usr/lib

My make is now progressing.  Hope this helps explain what is going on behind the scenes for this obscure error condition.

I have found the solution:

--- openssl-0.9.8i/Makefile.shared      2009-12-16 00:27:33.667686278 -0500
+++ openssl-0.9.8i.fixed/Makefile.shared        2009-12-15 23:35:17.035659855 -0500
@@ -94,7 +94,7 @@
     LIBPATH=`for x in $$LIBDEPS; do if echo $$x | grep '^ *-L' > /dev/null 2>&1; then echo $$x | sed -e 's/^ *-L//'; fi; done | uniq`; \
     LIBPATH=`echo $$LIBPATH | sed -e 's/ /:/g'`; \
     LD_LIBRARY_PATH=$$LIBPATH:$$LD_LIBRARY_PATH \
-    $${LDCMD} $${LDFLAGS} -o $${APPNAME:=$(APPNAME)} $(OBJECTS) $${LIBDEPS} )
+    $${LDCMD} $${LDFLAGS} -Wl,-EB -o $${APPNAME:=$(APPNAME)} $(OBJECTS) $${LIBDEPS} )

LINK_SO=       \
   ( $(SET_X);   \


I have tried to set TARGET_LDFLAGS+=-Wl,-EB in package/openssl/Makefile but it does not work. The -EB needs to be fed to the final linking process.

(Last edited by khteh on 16 Dec 2009, 06:44)

The discussion might have continued from here.