
#9589: Building GHC as a cross-compiler for armhf fails with undefined reference to `dlopen', `dlerror', `dlsym' -------------------------------------+------------------------------------- Reporter: jpmasseria | Owner: Type: bug | Status: infoneeded Priority: normal | Milestone: Component: Build | Version: 7.8.3 System | Keywords: Resolution: | Architecture: Unknown/Multiple Operating System: Linux | Difficulty: Unknown Type of failure: Building | Blocked By: GHC failed | Related Tickets: Test Case: | Blocking: | Differential Revisions: | -------------------------------------+------------------------------------- Comment (by jpmasseria): Success! I manually created the symlinks that `libc6-dev` creates between `/usr/lib/` to `/lib` as relative links as described in the StackOverflow posting you provided [http://stackoverflow.com/questions/13626726/an- error-building-qt-libraries-for-the-raspberry-pi] and the build completed. Here are the symlinks I created: {{{ johnma@aspire-ubuntu:~$ ls -l rpi-toolchain/rootfs/usr/lib/arm-linux- gnueabihf/ | grep "../.." lrwxrwxrwx 1 johnma johnma 44 Sep 17 19:07 libanl.so -> ../../../lib /arm-linux-gnueabihf/libanl.so.1 lrwxrwxrwx 1 johnma johnma 53 Sep 17 19:08 libBrokenLocale.so -> ../../../lib/arm-linux-gnueabihf/libBrokenLocale.so.1 lrwxrwxrwx 1 johnma johnma 45 Sep 17 19:08 libcidn.so -> ../../../lib/arm-linux-gnueabihf/libcidn.so.1 lrwxrwxrwx 1 johnma johnma 46 Sep 17 19:08 libcrypt.so -> ../../../lib/arm-linux-gnueabihf/libcrypt.so.1 lrwxrwxrwx 1 johnma johnma 43 Sep 17 18:50 libdl.so -> ../../../lib /arm-linux-gnueabihf/libdl.so.2 lrwxrwxrwx 1 johnma johnma 42 Sep 17 19:08 libm.so -> ../../../lib /arm-linux-gnueabihf/libm.so.6 lrwxrwxrwx 1 johnma johnma 44 Sep 17 19:08 libnsl.so -> ../../../lib /arm-linux-gnueabihf/libnsl.so.1 lrwxrwxrwx 1 johnma johnma 51 Sep 17 19:08 libnss_compat.so -> ../../../lib/arm-linux-gnueabihf/libnss_compat.so.2 lrwxrwxrwx 1 johnma johnma 48 Sep 17 19:08 libnss_dns.so -> ../../../lib/arm-linux-gnueabihf/libnss_dns.so.2 lrwxrwxrwx 1 johnma johnma 50 Sep 17 19:08 libnss_files.so -> ../../../lib/arm-linux-gnueabihf/libnss_files.so.2 lrwxrwxrwx 1 johnma johnma 51 Sep 17 19:08 libnss_hesiod.so -> ../../../lib/arm-linux-gnueabihf/libnss_hesiod.so.2 lrwxrwxrwx 1 johnma johnma 52 Sep 17 19:08 libnss_nisplus.so -> ../../../lib/arm-linux-gnueabihf/libnss_nisplus.so.2 lrwxrwxrwx 1 johnma johnma 48 Sep 17 19:08 libnss_nis.so -> ../../../lib/arm-linux-gnueabihf/libnss_nis.so.2 lrwxrwxrwx 1 johnma johnma 47 Sep 17 19:08 libresolv.so -> ../../../lib/arm-linux-gnueabihf/libresolv.so.2 lrwxrwxrwx 1 johnma johnma 43 Sep 17 19:08 librt.so -> ../../../lib /arm-linux-gnueabihf/librt.so.1 lrwxrwxrwx 1 johnma johnma 50 Sep 17 19:08 libthread_db.so -> ../../../lib/arm-linux-gnueabihf/libthread_db.so.1 lrwxrwxrwx 1 johnma johnma 45 Sep 17 19:08 libutil.so -> ../../../lib/arm-linux-gnueabihf/libutil.so.1 johnma@aspire-ubuntu:~$ }}} On my system the links did not exist at all. I had copied the `/lib` and `/usr/lib` from my target machine to my build machine using `rsync`. It is possible that my target machine did not have `libc6-dev` installed. My target machine is down right now so I can't tell that for sure. However, bottom line, for me to build a stage1 cross-compiler for a Raspberry Pi I had to create the relative symlinks shown above. I also had to create a short script to call `gcc` using `--sysroot` pointing to my local sysroot with my target `/lib` and `/usr/lib` directories as follows where `arm-linux-gnuabihf-gcc` is the cross-compiler from [https://github.com/raspberrypi/tools] installed on my build machine: {{{ johnma@aspire-ubuntu:~$ cat mygcc #!/bin/bash arm-linux-gnueabihf-gcc --sysroot=/home/johnma/rpi-toolchain/rootfs $@ johnma@aspire-ubuntu:~$ }}} And then used this `./configure` command: {{{ ./configure --target=arm-linux-gnueabihf --enable-unregisterised --with- gcc=/home/johnma/mygcc --with-nm=/usr/bin/nm }}} I tested my build as follows: {{{ johnma@aspire-ubuntu:~$ ./ghc/inplace/bin/ghc-stage1 haq.hs [1 of 1] Compiling Main ( haq.hs, haq.o ) Linking haq ... johnma@aspire-ubuntu:~$ johnma@aspire-ubuntu:~$ file haq haq: ELF 32-bit LSB executable, ARM, EABI5 version 1 (SYSV), dynamically linked (uses shared libs), for GNU/Linux 2.6.32, Buil dID[sha1]=26c431c1e98551502c244089c9028ce7e83b7a30, not stripped johnma@aspire-ubuntu:~$ johnma@aspire-ubuntu:~$ cat haq.hs -- -- Copyright (c) 2006 Don Stewart - http://www.cse.unsw.edu.au/~dons/ -- GPL version 2 or later (see http://www.gnu.org/copyleft/gpl.html) -- import System.Environment -- | 'main' runs the main program main :: IO () main = getArgs >>= print . haqify . head haqify s = "Haq! " ++ s }}} -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/9589#comment:8 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler