7

I need that to use mksdcard from the Android SDK. Currently, when I run that executable, the system reports "No such file or directory".

For Debian, one can install ia32-libs. On Ubuntu, the package is called libc6-i386.

How do I get the file /lib/ld-linux.so.2 on NixOS?

4
  • Have you already referred to these link:- sandervanderburg.blogspot.in/2012/11/… or sandervanderburg.blogspot.in/2014/02/… ? May 18, 2015 at 13:59
  • What do you mean by 32-bit runtime linker? Are you saying you want to know how to install a 32-bit version of ld? Usually you'd just have ld link 32-bit libraries/objects. What are trying to do with the "32-bit runtime linker" that you are not able to do now? Aug 28, 2015 at 16:48
  • @ssnobody, sorry, I should have said "dynamic linker", but I think "runtime" makes more sense. The file is called /lib64/ld-linux-x86-64.so.2 for 64-bit executables and /lib/ld-linux.so.2 for 32-bit. I confirmed this by compiling a sample C program with and without -m32 and then running ldd on it. Aug 28, 2015 at 17:24
  • @ssnobody regarding your question "what are you trying to do [...] that you are not able to do now": With a 32-bit dynamic linker, I can execute dynamically linked 32-bit executables. Aug 28, 2015 at 17:37

3 Answers 3

4
+100

NixOS does not natively have multiarch support.

The only Nix package which contains the 32-bit ELF interpreter ld-linux.so.2 file is the i386 version of glibc.

Luckily, we can work around the issue by borrowing the package from debian.

  1. Install dpkg: nix-env -i dpkg
  2. Download the libc-i386 package for 64-bit systems from debian: curl -O http://ftp.us.debian.org/debian/pool/main/e/eglibc/libc6-i386_2.11.3-4_amd64.deb
  3. Extract that package: dpkg -x libc6-i386_2.11.3-4_amd64.deb libc6-i386
  4. Run mksdcard with 32-bit ELF interpreter: ./libc6-i386/lib32/ld-linux.so.2 /path/to/mksdcard

One way to be able to run things like mksdcard via ./mksdcard is to patch them using patchelf installed via: nix-env -i patchelf

You can then do something like patchelf --set--interpreter /path/to/libc6-i386/lib32/ld-linux.so.2 /path/to/mksdcard

Otherwise, you may try to place symlinks to your ld-linux.so.2 in the places where ldd is telling you it expects them.

[root@nixos:/tmp]# ./libc6-i386/lib32/ld-linux.so.2
Usage: ld.so [OPTION]... EXECUTABLE-FILE [ARGS-FOR-PROGRAM...]
You have invoked `ld.so', the helper program for shared library executables.
This program usually lives in the file `/lib/ld.so', and special directives
in executable files using ELF shared libraries tell the system's program
loader to load the helper program from this file.  This helper program loads
the shared libraries needed by the program executable, prepares the program
to run, and runs it.  You may invoke this helper program directly from the
command line to load and run an ELF executable file; this is like executing
that file itself, but always uses this helper program from the file you
specified, instead of the helper program file specified in the executable
file you run.  This is mostly of use for maintainers to test new versions
of this helper program; chances are you did not intend to run this program.

  --list                list all dependencies and how they are resolved
  --verify              verify that given object really is a dynamically linked
                        object we can handle
  --library-path PATH   use given PATH instead of content of the environment
                        variable LD_LIBRARY_PATH
  --inhibit-rpath LIST  ignore RUNPATH and RPATH information in object names
                        in LIST
  --audit LIST          use objects named in LIST as auditors
1
  • For packaging any 32 bit application to NixOS/nixpkgs, there should be a way to write a nix expression in a shell.nix or default.nix that does that for you. You just have to find the relevant nix expression that provides the i386 version of glibc and then build and link from source or patchelf from binary. Aug 19, 2017 at 2:47
0

You can try this code. (I am not sure whether it works, because I did this in my Fedora OS and also for Ubuntu OS)

Download the SDK from this code:

wget "http://dl.google.com/android/android-sdk_r24.1.2-linux.tgz"
  1. After the download is complete, extract the folder android-sdk-linux to your home directory.

    /home/user/android-sdk-linux

  2. Create an Environment Variable called ANDROID_HOME.

    ANDROID_HOME = /home/user/android-sdk-linux

And these two folders to your Environment PATH variable,

/home/user/android-sdk-linux/tools
/home/user/android-sdk-linux/platform-tools
  1. Now open Terminal and check all the binaries are working or not like 'android' and all. If it works, now execute the following two commands in terminal.

To download the Android ARM image and update the SDK execute this commands in terminal:

echo y | android update sdk --all --filter platform-tools,android-19,sys-img-armeabi-v7a-android-19 --no-ui --force

Now to create an AVD, execute this command in terminal:

echo no | android create avd -n emul -t android-19 -s 360x600 --abi default/armeabi-v7a

NOTE: In the above command 'emul' is the AVD name.

  1. Once these steps are completed, to launch the AVD you've created in the above step, execute the following command in terminal:

    emulator -avd emul -noskin -netfast

1
  • you're not answering the actual question... this issue is systematic of NixOS, it's not just about the Android SDK Aug 18, 2015 at 15:42
0

On the my version of NixOS, I was able to get a working mksdcard by issuing: nix-env -i android-sdk-24.1.2 after doing a nix-channel --update

[root@nixos:~]# /root/.nix-profile/bin/mksdcard
mksdcard: create a blank FAT32 image to be used with the Android emulator
usage: mksdcard [-l label] <size> <file>

  if <size> is a simple integer, it specifies a size in bytes
  if <size> is an integer followed by 'K', it specifies a size in KiB
  if <size> is an integer followed by 'M', it specifies a size in MiB
  if <size> is an integer followed by 'G', it specifies a size in GiB

Minimum size is 9M. The Android emulator cannot use smaller images.
Maximum size is 1099511627264 bytes, 1073741823K, 1048575M or 1023G

From Basic Package Management: "Nixpkgs is automatically added to your list of “subscribed” channels when you install Nix."

However, if you've removed the subscription or would rather "install an older version of [the] package than the one provided by the current contents of the channel" or if the android sdk package "has been removed from the channel" you can follow the One-Click Installation Procedure:

You can go to http://hydra.nixos.org/jobset/nixpkgs/trunk/channel/latest and click on any link for the individual packages for your platform. The first time you do this, your browser will ask what to do with application/nix-package files. You should open them with /nix/bin/nix-install-package. This will open a window that asks you to confirm that you want to install the package. When you answer Y, the package and all its dependencies will be installed. This is a binary deployment mechanism — you get packages pre-compiled for the selected platform type.

In this case, you'd be interested in x86_64 android-studio

My System info for reference

[root@nixos:~]# uname -a Linux nixos 3.18.20 #1-NixOS SMP Thu Jan 1 00:00:01 UTC 1970 x86_64 GNU/Linux

[root@nixos:~]# cat /etc/issue

<<< Welcome to NixOS 15.09.10.4a1c7fd (\m) - \l >>>
2
  • thank you, but these instructions are specific to the Android SDK. my primary interest is how to install the 32-bit runtime linker, because that would probably be useful in the future also. Aug 28, 2015 at 11:37
  • Your comment to the previous answer made it seem to me like you wanted NixOS specific instructions for installing the Android SDK. Aug 28, 2015 at 20:04

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .