How to install gdb on MacOS terminal Sierra - macos

I searched online about how to install gdb on macOS Sierra 10.12.2 but failed on the methods I could find. Then I figure out the following way which is easy and works fine on my machine. hope it may help you too:)

download the most recent GDB from https://www.sourceware.org/gdb/download/
expand the gdb-7.12.1.tar.xz file: tar xopf gdb-7.12.1.tar.xz
cd gdb-7.12.1 in terminal to open the gdb folder
then follow the instructions in the README file in the gdb folder, or simply follow the following steps:
./configure, wait for the terminal
make and wait again (which can take some time)
sudo make install
Now gdb is installed at /usr/local/bin/

Note that you might want to try/use LLDB (lldb) instead. This is now the default (don't know about 10.12, but on 10.13 it is installed, when you install the Xcode utilities). It even comes with a nice curses GUI, but otherwise a shell very similar to GDB.

You can also use homebrew to get gdb in mac os:
install-gdb-macos-sierra

Surprised no one mentioned:
brew install gdb
How to install brew?

Related

Skip installation of Command Line Tools when installing Homebrew on macos

I am installing homebrew on macOS High Sierra 10.13. I have already installed the Command Line Tools for Xcode which is a requirement for homebrew. When installation of homebrew starts I am forced to install command line tools (or abort). When I do this the installation process hangs. I don't understand why this hangs but more importantly I don't understand why it is trying to install CLT when I can show that they are already available on my machine.
Right click the link below and save it as homebrew-install.sh
https://raw.githubusercontent.com/Homebrew/install/master/install.sh
Open homebrew-install.sh with a text editor and change the definition of the method should_install_command_line_tools to return 1
Make homebrew-install.sh executable (by running chmod u+x homebrew-install.sh) and then run ./homebrew-install.sh
In my case the xcode command line tools can be installed.
My environment is mac os.
In the terminal please enter
xcode-select --install
And it takes a little time to install
Check out macOS requirements in this article [https://docs.brew.sh/Installation]
good luck.

Brew install on Mojave

I did these steps:
Updated to Mojave
Installed Xcode 10 beta3
Ran this command: sudo xcode-select -switch /Applications/Xcode-beta.app/
Now I'm trying to install node8:
brew install node#8
And it gives me this error:
Error: The Command Line Tools header package must be installed on Mojave.
The installer is located at: /Library/Developer/CommandLineTools/Packages/macOS_SDK_headers_for_macOS_10.14.pkg
Still, doing
install -pkg /Library/Developer/CommandLineTools/Packages/macOS_SDK_headers_for_macOS_10.14.pkg
does nothing, since there's no such file in my system. Where could I get it?
Go to /Library/Developer/CommandLineTools/Packages/macOS_SDK_headers_for_macOS_10.14.pkg location and install package manually. And brew will start working.
I want to try and answer this question and also for those that come later that installed Mojave and had an older Xcode version installed. The process is the same minus that if you have Xcode 10, you don't need to install it again from my understanding.
The folder is hidden and was not accessible even with a sudo find command, however, I figured out that copying the absolute path and then pasting it in your browser address bar will give you the download and access to the folder that you need to fix brew install.
I posted a video here- https://youtu.be/GfnhSirTCGM that walks you thru part of my steps above. After you do the SDK headers download, its likely that unless you already are running Xcode 9.4, you will need to visit, https://developer.apple.com/download/more/ and look for Xcode 9.4 to install. Also grab the 10.14 command line tools as well. The lesson that should be learned here is that Apple calls it "Beta" for a reason and if you are a developer that knows the pains of setup, it is a bad idea. I hope that I was helpful! The last thing is, INSTALL XCODE THEN COMMAND LINE TOOLS-IN THAT ORDER OR IT ERRORS OUT! and then we do this all over again. Cheers!
It appears as though Apple has released a patch for the bug and it is available through the system preferences. 14 July 2018
Broken command line tools:
Xcode Location on the Apple developers website:
Location of command line tools:
Do not install Xcode from the Mac App Store because a different version is required!
Command line tools 10.14 update:
As of October 2018, the solution for making brew and brew install succeed is to:
install latest Xcode fom AppStore
run Xcode and install command line tools
add the line before to your profile or somethign similar
export CFLAGS="-I/usr/local/include -L/usr/local/lib -I$(brew --prefix openssl)/include -I$(xcrun --show-sdk-path)/usr/include"
No need to download Xcode manually, but you may want to remove the beta version if you installed it.
The magic part is at the end, where xcrun obtains the correct location of the SDK.
In terminal, you should first input the commands below
cd /Library/Developer/CommandLineTools/Packages
open .
you will open the directory on desktop,
then double click the pkg file to install it.

cannot run gdb on mac's terminal even after codesign

I'm trying to install gdb on my Mac. I downloaded it with brew and code signed it according to the instructions on https://sourceware.org/gdb/wiki/BuildingOnDarwin
However, when I run gdb in the terminal, it still doesn't work and output the following error message:
dyld: Library not loaded: /usr/local/opt/mpfr/lib/libmpfr.6.dylib
Referenced from: /usr/local/bin/gdb
Reason: image not found
Trace/BPT trap: 5
Does anyone know what it means? My Mac version is 10.11.5, by the way
I ran into the same issue on macOS 10.11.6, I'm guessing (and this is just speculation; I don't actually know how Homebrew works) that Homebrew installed a pre-compiled version of gdb which depended on a library that existed on the machine it was compiled with, but did not exist on my machine.
At any rate, I was able to get a working version of gdb by downloading & unzipping version 7.12 (8.1 failed to compile on my machine) from http://ftp.gnu.org/gnu/gdb/gdb-7.12.tar.gz, then compiling & installing with (IIRC) the commands:
./configure
make
sudo make install
I blogged about this and the subsequent steps (getting the executable code-signed so that macOS would allow it to debug other processes, etc) here: http://prust.github.io/posts/2018-02-24-interactively-debugging-c-in-sublime-text-3.html
I get this problem too. And I find solution in https://qiita.com/yoshixj/items/698d94337ca447e9b9de
Since we don't have /usr/local/opt/mpfr/lib/libmpfr.6.dylib
we can simply install it. Use this command:
brew install gawk
echo 'export PATH="/usr/local/opt/gettext/bin:$PATH"' >> ~/.zshrc
I had the same error message when running gdb after installing it from Homebrew (gdb v8.1) on a Mac OS X El Capitan v10.11.6. However, installing it via Homebrew using its Python binary solved the issue:
brew install gdb --with-python
Beaware that this may take some time, since you'd be compiling gdb from scratch. After it's done, you still need to create a certificate and codesign gdb.

OS X Terminal hangs installing vNext KVM after running "source kvm.sh"

I'm trying to install vNext on my Macbook but when I run source kvm.sh the terminal just hangs.
My setup:
OSX 10.9.5 (Mavericks)
Mono 3.10.0
My problem:
I followed the instructions for installing vNext on OS X from the GitHub repo:
https://github.com/aspnet/Home
Essentially:
brew tap aspnet/k
brew install kvm
source kvm.sh
Everything seems to go fine until the step where I run source kvm.sh, which hangs the terminal with a message "[Process completed]".
Adding source kvm.sh to ~/.zshrc file starts the terminal and immediately hangs it once that runs.
What I've tried:
I uninstalled kvm (brew uninstall kvm) and aspnet/k (brew untap aspnet/k) and deleted the directory ~/.kre, then tried reinstalling it all again.
No luck.
Any ideas? Here's a screenshot:
The kvm currently not working in ZSH, Running it under /bin/bash should work quite well.
Also, make sure you remove anything to do with kvm from your .zshrc file and you should be good to go again.
according to https://github.com/aspnet/kvm/issues/83 , you can replace the kvm.sh file with the version from dev branch, which can be found under https://github.com/aspnet/kvm/blob/dev/src/kvm.sh , and zsh should be happy with it afterwards.
Worked for me.

cannot link homebrew emacs

Recently I uninstalled and reinstalled Homebrew entirely on my macbook (OSX 10.9.5) because there was some problem with my Python. Then I reinstalled all the programs in Homebrew and everything worked fine except for Emacs. When I tried to link emacs
$ brew link emacs
Linking /Users/myname/homebrew/Cellar/emacs/24.3... 21 symlinks created
I expected it to create a shortcut in Applications and I open the Emacs GUI from there, but Emacs is not showing up there and I don't know how I can open the GUI. What did I do wrong and how can I link my Emacs?
Try running it from the command line to see what's wrong:
emacs --debug-init
The program is likely not able to find some elc files or something among those lines.
If all fails, try using the master branch (I update my emacs frequently, such as today).
brew install emacs --HEAD --use-git-head --cocoa --srgb --with-xml2 && brew linkapps

Resources