Debugging an unknown Linux box - linux

I have a Linux box that I have root access to, using SSH.
I want to use GDB to debug the system.
It's a stripped-down Debian package; therefore, I don't have any compile tools in it.
uname -a gives:
2.6.38.6-41 SMP XXXXXXX 2014 i686 GNU/Linux
What is the best way to install GDB on it?
I have tried to download the GDB binaries i386, but it always require a different library installed, so if I install all the compatible libraries asked for gdb then I may corrupt the original system.
How can I achieve the GDB instalation goal?
Thanks
There is no apt-get executable installed.
There is no compiler tools installed.
No file in /etc/lsb_release.

If you have Debian package then you can install gdb using following command
sudo apt-get install gdb

Related

objdump is missing from windows10 pro (msys2 installed)

I have installed msys2 using chocolatey.
I have tried msys2-installer module from chocolatey too.
But I can not find objdump on my system. Should I install something more ?
MSYS2 supports three different compiler toolchains, all with their own objdump utility. I'm not sure which one you want to use, but you can just install them all by running:
sudo pacman -S binutils mingw-w64-x86_64-binutils mingw-w64-i686-binutils

aapt missing but its there

I had to reinstall ubuntu-14.04-64 due to reasons.
After this reinstall, when I try to build my android projets, I get a bunch of these lines (among others) in output:
java.io.IOException: Cannot run program "/home/gps/Android/Sdk/build-tools/23.0.2/aapt": error=2, No such file or directory
Now, I know this file exists in my setup because this:
gps#gps-HP-ProBook-4540s:~$ ls -l /home/gps/Android/Sdk/build-tools/23.0.2/aapt
-rwxrwxr-x 1 gps gps 1146608 Jan 4 18:47 /home/gps/Android/Sdk/build-tools/23.0.2/aapt
gps#gps-HP-ProBook-4540s:~$ file /home/gps/Android/Sdk/build-tools/23.0.2/aapt
/home/gps/Android/Sdk/build-tools/23.0.2/aapt: ELF 32-bit LSB shared object, Intel 80386, version 1 (SYSV), dynamically linked (uses shared libs), for GNU/Linux 2.6.24, BuildID[sha1]=fc8aded5418584519d59f2133e81184fe3d4bdfd, not stripped
gps#gps-HP-ProBook-4540s:~$
I have installed all sdk tools from v19 onwards. Changing project settings to any of them shows same error.
Also, trying to execute the file directly gives same error:
gps#gps-HP-ProBook-4540s:~$ /home/gps/Android/Sdk/build-tools/23.0.2/aapt
bash: /home/gps/Android/Sdk/build-tools/23.0.2/aapt: No such file or directory
Can someone suggest a solution to this problem?
Problem solved as follows:
Issue was missing 32 bit libraries, libc and zlib in this case. Installed using following :
sudo apt-get install libc6:i386
sudo apt-get install zlib1g-dev:i386
Thanks #Joni for clear directions.
You're probably missing some dynamic link library that the program needs. Run this command to list the libraries it uses and install those that are missing:
ldd /home/gps/Android/Sdk/build-tools/23.0.2/aapt
Solution as of Ubuntu 16.04 / 16.10 to enable 32 bit binaries to run on 64 bit host
sudo dpkg --add-architecture i386
sudo apt-get -qqy update
sudo apt-get -qqy install libncurses5:i386 libstdc++6:i386 zlib1g:i386

error while loading shared libraries: libncurses.so.5:

I've installed Android Studio and tried to run my first project in it, and I've got following error:
Error Output was: /home/user/android-studio/sdk/platform-tools/adb: error while loading shared libraries: libncurses.so.5: cannot open shared object file: No such file or directory
I've already tried to run
sudo ldconfig
but it doesnt help. I've recently installed libncurses (before using android studio).
What should I do?
If libncurses is not installed then install it and try again.
for 32-bit binaries : sudo apt-get install libncurses5:i386
for 64-bit binaries :
sudo apt-get install libncurses5
Also install the collection of libraries by using this command,
sudo apt-get install ia32-libs
error while loading shared libraries: libncurses.so.5
If you see this, your distro probably has a newer version of libncurse installed. First find out what version of libncurses your distro has:
$ ls -1 /usr/lib/libncurses*
/usr/lib/libncurses.so
/usr/lib/libncurses++.so
/usr/lib/libncurses++w.so
/usr/lib/libncursesw.so
/usr/lib/libncurses++w.so.6
/usr/lib/libncursesw.so.6
/usr/lib/libncurses++w.so.6.0
/usr/lib/libncursesw.so.6.0
In this case, we are dealing with version 6, so we make two symlinks:
$ sudo ln -s /usr/lib/libncursesw.so.6.0 /usr/lib/libncurses.so.5
$ sudo ln -s /usr/lib/libncursesw.so.6.0 /usr/lib/libtinfo.so.5
After this, the program should run normally.
If you are absolutely sure that libncurses, aka ncurses, is installed, as in you've done a successful 'ls' of the library, then perhaps you are running a 64 bit Linux operating system and only have the 64 bit libncurses installed, when the program that is running (adb) is 32 bit.
If so, a 32 bit program can't link to a 64 bit library (and won't locate it anyway), so you might have to install libcurses, or ncurses (32 bit version). Likewise, if you are running a 64 bit adb, perhaps your ncurses is 32 bit (a possible but less likely scenario).
For Redhat Linux 8 try this:
sudo yum install libncurses*
On Arch Linux you can install ncurses5-compat-libs AUR package.
FYI it is mentioned in Arch Wiki android page, just in case if you'll need some other dependencies for Android Studio: https://wiki.archlinux.org/index.php/Android
For Redhat Linux this helped,
sudo yum install ncurses-compat-libs
In Fedora 28 use:
sudo dnf install ncurses-compat-libs
I solved the issue using
ln -s libncursesw.so.5 /lib/x86_64-linux-gnu/libncursesw.so.6
on ubunutu 18.10
On Arch, i fix like this:
sudo ln -s /usr/lib/libncursesw.so.6 /usr/lib/libtinfo.so.6
To install ncurses-compat-libs on Fedora 24 helped me on this issue
(unable to start adb error while loading shared libraries: libncurses.so.5)
Your system likely does not provide the ncurses library at the version android studio uses. My arch linux install only had ncurses 6 but android studio needs version 5.
You could check if your distribution has a compatability package, or use the solution that Rahmat Aligos suggested.
Mixaz's above answer worked for me. However I had issues installing the package because of PGP check failures. Installing it by skipping the signature worked, you could try this :
yaourt --m-arg "--skipchecksums --skippgpcheck" -Sb <your-package>

gcc-arm-linux-gnueabi command not found

I am trying to install the gnu arm toolchain for ubuntu. I first downloaded the tar from CodeSourcery. However when I go into the bin folder, I cannot run any of the binaries. I have tried with ./ and without and putting it in the PATH and it keeps telling me "Command not Found" yet the file is there in the folder right in front of me. Then I tried sudo apt-get install gcc-arm-linux-gnueabi except after it says it has installed successfully, I cannot find it with whereis gcc-arm-linux-gnueabi. Can anyone help?
fixed, using:
sudo apt-get install gcc-arm*
Are you compiling on a 64-bit OS? Try:
sudo apt-get install ia32-libs
I had the same problem when trying to compile the Raspberry Pi kernel. I was cross-compiling on Ubuntu 12.04 64-bit and the toolchain requires ia32-libs to work on on a 64-bit system.
See http://hertaville.com/2012/09/28/development-environment-raspberry-pi-cross-compiler/
CodeSourcery convention is to use prefix arm-none-linux-gnueabi- for all executables, not gcc-arm-linux-gnueabi that you mention. So, standard name for CodeSourcery gcc would be arm-none-linux-gnueabi-gcc.
After you have installed CodeSourcery G++, you need to add CodeSourcery directory into your PATH.
Typically, I prefer to install CodeSourcery into directory like /opt/arm-2010q1 or something like that. If you don't know where you have installed it, you can find it using locate arm-none-linux-gnueabi-gcc, however you may need to force to update your locate db using sudo updatedb before locate will work properly.
After you have identified where your CodeSourcery is installed, add it your PATH by editing ~/.bashrc like this:
PATH=/opt/arm-2010q1/bin:$PATH
Also, it is customary and very convenient to define
CROSS_COMPILE=arm-none-linux-gnueabi-
in your .bashrc, because with CROSS_COMPILE defined, most tools will automatically use proper compiler for ARM compilation without you doing anything.
if you are on 64 bit os then you need to install this additional libraries.
sudo apt-get install lib32z1 lib32ncurses5 lib32bz2-1.0
got the same error when trying to cross compile the raspberry pi kernel on ubunto 14.04.03 64bit under VM. the solution was found here:
-Install packages used for cross compiling on the Ubuntu box.
sudo apt-get install gcc-arm-linux-gnueabi make git-core ncurses-dev
-Download the toolchain
cd ~
git clone https://github.com/raspberrypi/tools
-Add the toolchain to your path
PATH=$PATH:~/tools/arm-bcm2708/gcc-linaro-arm-linux-gnueabihf-raspbian:~/tools/arm-bcm2708/gcc-linaro-arm-linux-gnueabihf-raspbian-x64/bin
notice the x64 version in the path command
I was also facing the same issue and resolved it after installing the following dependency:
sudo apt-get install lib32z1-dev
If you are on a 64bit build of ubuntu or debian (see e.g. 'cat /proc/version') you should simply use the 64bit cross compilers, if you cloned
git clone https://github.com/raspberrypi/tools
then the 64bit tools are in
tools/arm-bcm2708/gcc-linaro-arm-linux-gnueabihf-raspbian-x64
use that directory for the gcc-toolchain.
A useful tutorial for compiling that I followed is available here Building and compiling Raspberry PI Kernel (use the -x64 path from above as ${CCPREFIX})
You have installed a toolchain which was compiled for i686 on a box which is running an x86_64 userland.
Use an i686 VM.
Its a bit counter-intuitive. The toolchain is called gcc-arm-linux-gnueabi. To invoke the tools execute the following: arm-linux-gnueabi-xxx
where xxx is gcc or ar or ld, etc
try the following command:
which gcc-arm-linux-gnueabi
Its very likely the command is installed in /usr/bin.
I had to cross compile C code in Ubuntu for ARM. This worked for me:
$ sudo apt install gcc-arm-none-eabi
Later, tested it on the qemu emulator
#Install qemu
sudo apt-get install qemu qemu-user-static qemu-system-arm
#Cross compile "helloworld.c"
$ arm-none-eabi-gcc --specs=rdimon.specs -Wl,--start-group -lgcc -lc -lm -lrdimon -Wl,--end-group helloworld.c -o helloworld
#Run
qemu-arm-static helloworld

Can't build 32bit Wine on 64bit linux

I'm trying to do this:
Build 32bit on 64 bit Linux using an automake configure script?
Doesn't work for me :(
Compileing wine. I found this in config.log:
configure: failed program was:
| /* confdefs.h */
| #define PACKAGE_NAME "Wine"
| #define PACKAGE_TARNAME "wine"
| #define PACKAGE_VERSION "1.5.19"
| #define PACKAGE_STRING "Wine 1.5.19"
| #define PACKAGE_BUGREPORT "wine-devel#winehq.org"
| #define PACKAGE_URL "http://www.winehq.org"
| /* end confdefs.h. */
|
| int
| main ()
| {
|
| ;
| return 0;
| }
Configuration fails with: Cannot build a 32-bit program, you need to install 32-bit development libraries.
apt-get install gcc-multilib libasound2-dev:i386 libgsm1-dev:i386 libjpeg8-dev:i386 liblcms2-dev:i386 libldap2-dev:i386 libmpg123-dev:i386 libopenal-dev:i386 libv4l-dev:i386 libx11-dev:i386 libxinerama-dev:i386 libxml2-dev:i386 zlib1g-dev:i386
and
apt-get install libcapi20-dev:i386 libcups2:i386 libdbus-1-3:i386 libfontconfig:i386 libfreetype6:i386 libglu1-mesa:i386 libgnutls26:i386 libgphoto2-2:i386 libncurses5:i386 libosmesa6:i386 libsane:i386 libxcomposite1:i386 libxcursor1:i386 libxi6:i386 libxrandr2:i386 libxslt1.1:i386 ocl-icd-libopencl1:i386
got me past X error.
To build 32-bit wine on 64-bit machine, you can use LXC (Linux Containers) which is an operating-system-level virtualization environment for running multiple isolated Linux systems. It's the easiest solution so far, as Linux (such as Ubuntu or Debian) makes building 32-bit wine hard because the 64-bit system doesn't come with a full set of 32-bit development libraries (See: Bug #990982).
So the basic approach to compile both 32-bit and 64-bit wine is:
Build 64-bit wine
Build 32-bit tools in lxc
Build 32-bit wine in lxc, referring to the 64-bit wine and 32-bit tools 1. built in the previous steps
Install 32-bit wine
Install 64-bit wine
On the page Building Biarch (Shared WoW64) Wine On Ubuntu we can read the following instructions:
Install the 64-bit prerequisites:
sudo apt-get update
sudo apt-get build-dep wine
Build 64-bit wine:
mkdir $HOME/wine64
cd $HOME/wine64
../wine-git/configure --enable-win64
make -j4
Install lxc:
sudo apt-get install lxc
Create a 32-bit container named "my32bitbox" using the Ubuntu
template and bind your home directory to the /home directory in the
container:
sudo lxc-create -t ubuntu -n my32bitbox -- --bindhome $LOGNAME -a i386
Copy the apt configuration from the host to the lxc container:
sudo cp -R /etc/apt /var/lib/lxc/my32bitbox/rootfs/etc
Start the container; at the console login prompt it gives you, log
in with your username and password.
sudo lxc-start -n my32bitbox
Now you're inside the container, in your real home directory. If you
are not in the container (you do not have the prompt
username#my32bitbox), then open a new terminal and:
sudo lxc-attach -n my32bitbox
login yourusername+password
Now, you are in the container. Do an out-of-tree build of Wine as
normal, just to get the tools. You'll have to install all the needed
prerequisites first. For instance:
sudo apt-get update
sudo apt-get install python-software-properties git-core
sudo apt-get build-dep wine
mkdir $HOME/wine32-tools
cd $HOME/wine32-tools
~/wine-git/configure
make -j4
Still inside the container, do it again, this time pointing to the
64-bit build for data, and the 32-bit tools build for tools:
mkdir $HOME/wine32
cd $HOME/wine32
~/wine-git/configure --with-wine64=$HOME/wine64 --with-wine-tools=$HOME/wine32-tools
make -j4
Still inside the container, install the 32-bit wine to force the
last little bit of building:
cd $HOME/wine32
sudo make install
While still inside the container, shut it down:
sudo shutdown -h now
This drops you back out into your real machine. Next, you need to
remove all existing Wine packages. You can do this from the command
line but it's probably easier with aptitude or one of the GUI
package management tools. You will need wine-mono, wine-gecko, and
optionally winetricks for your compiled version of wine. However,
these packages may depend on the existing wine installation which
may force you to remove them.
Install the newly built wine into your real machine:
cd $HOME/wine32
sudo make install
cd $HOME/wine64
sudo make install
Warning: When you install a locally built version of Wine, the
package management system will not know it exists since it did not
come from a package. Thus it is possible to later break its
dependencies or install a conflicting version of wine without a
warning from the package management tools. You can prevent this by
creating a package or by blocking conflicting packages with
apt-pinning by setting "Pin-Priority: -1" for the packages.
Next, install Mono, Gecko, and optionally winetricks if you had to
remove their packages because of a dependency on a conflicting wine
package.
Notes:
Many of the above commands require root privileges. Your user account needs to have access to root via sudo or you need to switch to a user account.
It's not necessary to remove your distro version and 'install' your compiled versions (32bit, 64bit) You simply need to invoke your personal version of wine appropriate for the Windows app. For example: ~/wine32/wine32 ~/.wine/path_to_winapp/my_app.
What worked to some extent for me on Debian Wheezy:
dpkg --add-architecture i386
apt-get update
to enable installation from the i386 repos
apt-get install ia32-libs libc6-dev-i386 lib32z1-dev lib32bz2-dev
to install the 32 bit libs. I'm actually still having trouble with X libs:
configure: error: X 32-bit development files not found. Wine will be built
without X support, which probably isn't what you want. You will need
to install 32-bit development packages of Xlib/Xfree86 at the very least.
Use the --without-x option if you really want this.
but it's technically optional.
you may solve the X error:
sudo apt-get install xorg-dev
Don't do that. Wine builds for 32-bit by default even on 64-bit systems (since it has to run 32-bit Windows programs.) It also builds a 64-bit Wine at the same time. If you want to disable that, configure it with:
./configure --disable-win64
I guess you use Ubuntu x64 which now supports multi-architecture. In other words on a 64 bit system you can build only Wine-x64 version. Building 32bit Wine on Ubuntu 12.04 x64 seems to buggy as for now.
So just run:
./configure --enable-win64
The Wine wiki has an easy way to install the needed 32bit development libraries on a 64bit system, using chroot: http://wiki.winehq.org/WineOn64bit

Resources