15

I try to find out the triplet for my device, because i try to cross compile, but there is no gcc installed on the target device and i am not allowed to install it.

With gcc installed i could just write gcc -dumpmachine

Is it possible to find this information without gcc?

8
  • 1
    how far will uname -a get you here?
    – FelixJN
    Aug 25, 2015 at 11:59
  • 1
    i get Linux MyDeviceName 2.6.35.3-571-gcca29a0-g8b63513-dirty #162 PREEMPT Tue Aug 4 10:57:29 CEST 2015 armv5tejl GNU/Linux
    – Black
    Aug 25, 2015 at 12:09
  • 1
    Can you tell us the manufacturer and model of the target device, for example Freescale MX28EVK ? Aug 25, 2015 at 12:15
  • No i can't, its a small special device with a metal housing and nothing written on it.
    – Black
    Aug 25, 2015 at 12:21
  • 1
    So you have a armv5tejl core, GNU/Linux as OS, and if you really need the vendor, too, try lshw -class cpu and ignore the "should be run as super-user" part.
    – FelixJN
    Aug 25, 2015 at 12:23

3 Answers 3

14

You can get a lot of information by means of uname and also by checking with file the type of executables:

$ gcc -dumpmachine
x86_64-linux-gnu
$ uname -o -m
x86_64 GNU/Linux
$ file /usr/bin/file
/usr/bin/file: ELF 64-bit LSB executable, x86-64, version 1 (SYSV), dynamically linked, interpreter /lib64/ld-linux-x86-64.so.2, for GNU/Linux 2.6.32, BuildID[sha1]=d8ac02806880576708bf189c064fca78ea89f1d0, stripped

If your device doesn't have file installed, copy a binary executable from it to another Linux computer and run file there.

3
  • Thank you for your answer. Where can i find a binary executable? Under /usr/bin ? Sorry, im pretty much beginner, so an example would be great.
    – Black
    Aug 26, 2015 at 6:18
  • 1
    If you got the file command as shown in the snippet above you can use it itself as executable example. Otherwise any other file in /usr/bin should do. Aug 26, 2015 at 6:54
  • uname -o -m gives armv7l GNU/Linux instead of arm-linux-gnueabihf
    – Fuseteam
    May 26, 2021 at 1:01
5

You'll need to find files in the file system which preserve the triplet passed to / probed by configure on the build time of your target userland.

In common GNU/Linux distributions the best bet would be querying to common command binaries like bash curl make svn. In the following example on Debian/armhf (QEMU image taken from here) I got the canonical triplet arm-unknown-linux-gnueabihf by bash --version. So it would be basically safe to configure my cross toolchain for this system by /path/to/configure --target=arm-unknown-linux-gnueabihf.

root@debian-armhf:~# bash --version
GNU bash, version 4.2.37(1)-release (arm-unknown-linux-gnueabihf)
Copyright (C) 2011 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>

This is free software; you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.

There's no reliable way to know non-canonical triplet like arm-linux-gnueabihf x86_64-linux-gnu from the userland, and there might be distribution specific conventions like Debian multiarch and tuples. You'll need to collect info from your distribution's document or other resources online.

2
  • Thx for your answer, but unfortunattely the command "bash" is not available too.
    – Black
    Aug 26, 2015 at 11:34
  • Which distribution are you using Apr 23, 2017 at 13:49
2

Another option is make -v. In my laptop:

$ make -v 
GNU Make 4.1
Built for x86_64-pc-linux-gnu
Copyright (C) 1988-2014 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.

Then built triple is x86_64-pc-linux-gnu.

3
  • 1
    Turns out this answer is wrong. The build triplet is x86_64-linux-gnu despite what make says.
    – Joshua
    May 7, 2019 at 2:27
  • @Joshua Please read this: wiki.osdev.org/Target_Triplet
    – mja
    May 8, 2019 at 15:58
  • 1
    Most people need to know the triplet either to know what to pass to ./configure or to cross-compile something. When cross-compiling, the only name that is relevant is the name the cross tools will take.
    – Joshua
    May 8, 2019 at 16:06

You must log in to answer this question.

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