cannot run gdb on mac's terminal even after codesign - macos

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.

Related

How to install gdb on MacOS terminal Sierra

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?

GCC installed but not showing on OSX 10.9.5

I had a working gcc/g++(2 month back;can't remember) from terminal of my mavericks with Xcode & Command Line Tools 6.0.1(6A317) but its not working now(might be due to minor OS upgrade). I tried all the commands gcc, g++, clang but neither of them works. Again, I tried installing using MacPorts using sudo port install gcc49 and it completed successfully but still any of the commands doesn't works(even after restarting terminal).
Additional Information- When I look for gcc/g++ in /usr/bin/, there is only alias present.
But clang++ and clang are present in /usr/bin/.

Glut Error on Mac with Haskell Program

I am trying to run a Haskell program which has to use GLUT (to draw shapes) but I get this error message :
*** Exception: user error (unknown GLUT entry glutSetOption)
My program works and GLUT lauches when I run it on Linux
So I only get this problem from my Mac..
As user2141650 suggested in a comment, this seems to be caused by a discrepancy between the default macOS GLUT and freeGLUT. Since version 2.7.0.12, Haskell GLUT automatically picks freeGLUT if it's installed. Here's how I managed to install freeGLUT:
Install XQuartz:
brew cask install xquartz or
install the .dmg from xquartz.org.
brew install freeglut
After I installed XQuartz and freeGLUT with brew, my program still couldn't open the display. As suggested in this Reddit thread, I did the following:
launchctl load -w /Library/LaunchAgents/org.macosforge.xquartz.startx.plist
restarted my computer
Maybe the launchctl command would have been enough, or maybe restarting the computer would have done it, or maybe all that isn't necessary if you install XQuarts using the .dmg file. I don't know. Good luck!

Error building Omnet++: Cannot build Tcl/Tk apps on Mountain lion

I'm trying to Compile Omnet++ 4.1 on Mountain Lion. When I type:
./configure
I get the following error:
configure: error: Cannot build Tcl/Tk apps, probably due to misconfigured or missing X11 headers or libs. Check config.log for more info!
I remember compiling it on Lion without any problems, any ideas how to get it working on Mountain Lion?
Found a solution for this over on the omnetpp google group, I'll paste it in here:
Hi all,
just tried Mountain Lion, which was released yesterday. Unfortunately,
the new MacOSX does not include X11 by default. I really HATE this
decision. As a result, it does not pass the Tcl/Tk checks when we do
./configure.
After hours of efforts, I finally figured out how to work around this:
download and install XQuartz at http://xquartz.macosforge.org/landing/
make a symbolic link at /usr/include: sudo ln -s /opt/X11/include/X11 /usr/include
and you are all set. In 2, you may also set some environment variables
accordingly instead of making the symbolic link.
Future OMNet++ releases may consider setting associated environment
variables so that the compiler looks for Xlib.h in
/opt/X11/include/X11 with Mountain Lion.
Just successfully compiled the simulator and haven't encountered other
problems yet.
Have fun,
TS
If you have the same problem on Linux (ubuntu) a solution is run this in the console:
sudo apt-get install build-essential gcc g++ bison flex perl tcl-dev tk-dev blt libxml2-dev zlib1g-dev openjdk-6-jre doxygen graphviz openmpi-bin libopenmpi-dev libpcap-dev
Installing XQuartz is still the solution to overcome this problem.

Plotting with Octave after most recent MAC OSX update

Hi I just recently downloaded the most recent snow leopard update. Then I tried to plot something using Octave which has been installed on my computer for months (and plotting has worked all that time) Even since I installed the update, and I try to plot using octave I get the following error:
dyld: Library not loaded: /usr/X11/lib/libfreetype.6.dylib
Referenced from: /usr/X11R6/lib/libfontconfig.1.dylib
Reason: Incompatible library version: libfontconfig.1.dylib requires version 13.0.0 or later, but libfreetype.6.dylib provides version 10.0.0
dyld: Library not loaded: /usr/X11/lib/libfreetype.6.dylib
Referenced from: /usr/X11R6/lib/libfontconfig.1.dylib
Reason: Incompatible library version: libfontconfig.1.dylib requires version 13.0.0 or later, but libfreetype.6.dylib provides version 10.0.0
/Applications/Gnuplot.app/Contents/Resources/bin/gnuplot: line 71: 865 Trace/BPT trap GNUTERM="${GNUTERM}" GNUPLOT_HOME="${GNUPLOT_HOME}" PATH="${PATH}" DYLD_LIBRARY_PATH="${DYLD_LIBRARY_PATH}" HOME="${HOME}" GNUHELP="${GNUHELP}" DYLD_FRAMEWORK_PATH="${DYLD_FRAMEWORK_PATH}" GNUPLOT_PS_DIR="${GNUPLOT_PS_DIR}" DISPLAY="${DISPLAY}" GNUPLOT_DRIVER_DIR="${GNUPLOT_DRIVER_DIR}" "${ROOT}/bin/gnuplot-4.2.6" "$#"
/Applications/Gnuplot.app/Contents/Resources/bin/gnuplot: line 71: 871 Trace/BPT trap GNUTERM="${GNUTERM}" GNUPLOT_HOME="${GNUPLOT_HOME}" PATH="${PATH}" DYLD_LIBRARY_PATH="${DYLD_LIBRARY_PATH}" HOME="${HOME}" GNUHELP="${GNUHELP}" DYLD_FRAMEWORK_PATH="${DYLD_FRAMEWORK_PATH}" GNUPLOT_PS_DIR="${GNUPLOT_PS_DIR}" DISPLAY="${DISPLAY}" GNUPLOT_DRIVER_DIR="${GNUPLOT_DRIVER_DIR}" "${ROOT}/bin/gnuplot-4.2.6" "$#"
error: you must have gnuplot installed to display graphics; if you have gnuplot installed in a non-standard location, see the 'gnuplot_binary' function
I'm really not sure what to do. I'm way out of my league here.
The "note for MacOSX users" is no longer on the Octave homepage, and the workaround described in Marco's post didn't work for me either, but this did:
Open /Applications/Gnuplot.app/Contents/Resources/bin/gnuplot in a text
editor. Use the editor search-and-replace feature to replace
"DYLD_LIBRARY_PATH" with "DYLD_FALLBACK_LIBRARY_PATH". There are four
instances that need to be replaced.
This is from the readme for the Octave MacOSX Binary. Note that it says it's for Lion users, but I'm running 10.6.8 and it worked for me.
I've recently build Octave and GNUplot on Lion using homebrew. Seems to work well. Here are some notes
Install Xcode from AppStore and HomeBrew (see Link)
Run 'brew install octave" and wait until graphicsmagick fails to compile
Run the command "brew install --use-clang --HEAD graphicsmagick". You might be asked to install Mercurial, just follow the instructions. You may also be asked to install fortran, so "brew install gfortran"
Run the command "brew install octave" again
Install Aquaterm
Now run "brew install gnuplot"
You now have the latest Octave installed. Just type octave from the terminal
To test the install run the following commands at the Octave command prompt
setenv("GNUTERM", "x11");
x = linspace(-10, 10, 100);
y = sin(x);
plot(x,y);
See the note for users of Mac OS X 10.6 on http://octave.sourceforge.net/. The changes solve the problem also in 10.5.8.
We updated freetype in OSX 10.6.5 and fontconfig, which links against freetype, wants this newer version. Gnuplot is failing to load because their developers are setting DYLD_LIBRARY_PATH which is forcing our libfontconfig to try using their libfreetype, which it cant.
This is a bug in Gnuplot.app ... developers should NEVER be setting DYLD_LIBRARY_PATH in shipping products!
I had the same problem and took me a while to find the "note for users of Mac OS X 10.6". I copy them here:
NOTES FOR SNOW LEOPARD USERS
1 - mkoctfile
Since OSX 10.6 the Apple shipped version of gcc builds by default 64bit binaries
As the libraries included with Octave.app version 3.2.3 are 32bit, you need to apply
the following patch in order for mkoctfile to work:
1.1) open the folder /Applications in the finder
1.2) right-click on Octave.app and select "show package contents"
1.3) navigate to /Applications/Octave.app/Contents/Resources/bin
1.4) right-click on the file "mkoctfile" and select "Open with -> Other ... -> TextEdit.app"
1.5) right after the line:
# along with this program; If not, see <http://www.gnu.org/licenses/>.
add the lines
CFLAGS="-m32 ${CFLAGS}"
FFLAGS="-m32 ${FFLAGS}"
CPPFLAGS="-m32 ${CPPFLAGS}"
CXXFLAGS="-m32 ${CXXFLAGS}"
LDFLAGS="-m32 ${LDFLAGS}"
and save.
2 - Gnuplot.app
An update to system libraries introduced with OSX 10.6.5 has broken the functionality
of the Gnuplot.app included with the Octave.app distribution, in order to use Gnuplot.app
on OSX 10.6.5 and later, you can use the fix described below:
2.1) open the folder /Applications in the finder
2.2) right-click on Gnuplot.app and select "show package contents"
2.3) navigate to /Applications/Gnuplot.app/Contents/Resources/bin
2.4) right-click on the file "gnuplot" and select "Open with -> Other ... -> TextEdit.app"
2.5) change the line:
DYLD_LIBRARY_PATH="${ROOT}/lib:${DYLD_LIBRARY_PATH}"
to
DYLD_LIBRARY_PATH="${ROOT}/lib"
and save.
NOTES FOR LEOPARD USERS
An update to system libraries introduced with OSX 10.5.8 has broken the functionality
of the Gnuplot.app included with the Octave.app distribution, in order to use Gnuplot.app
on OSX 10.5.8 and later, you can use the same fix described above for OSX 10.6.5.
I tried the above and it did not help. The source of the problem seems to be the version of gnuplot that comes with the Octave.app install.
I installed gnuplot directly with 'brew' and then I removed gnuplot from my Applications folder. Once that change was made, Octave was able to find the newer version of gnuplot that was compiled with the correct dependencies.
If you don't mind using MacPorts, you can install octave by the following command. And it will be a 64-bit version.
sudo port install octave-devel
I just want to share my experience regarding this issue.
I had similar problem today when I tried to use Octave/Gnuplot in Mac OS X (10.7.5, Lion) and none of the solutions above worked for me.
However I found another solution that did work, which is described in https://github.com/jyr/MNPP/issues/28. Basically, I did the following:
sudo cp /usr/X11/lib/libfreetype.* /Applications/Gnuplot.app/Contents/Resources/lib
Mountain Lions can also install Octave 3.4.0 with the dmg and throw in the older 4.2 gnuplot instead from the Maxima dmg. Easiest, but not the most recent version. (A classmate's idea which worked.)
Replacing the 4 instances of "DYLD_LIBRARY_PATH" with "DYLD_FALLBACK_LIBRARY_PATH" did not work for me on Mac OS X 10.9.
However, the second option given here:
http://sourceforge.net/projects/octave/files/Octave%20MacOSX%20Binary/2011-04-21%20binary%20of%20Octave%203.4.0/
did work. i.e. using Gnuplot-4.2.6 that is bundled with Maxima DMG. Link below. http://sourceforge.net/projects/maxima/files/Maxima-MacOS/5.26.0-MacOSX/
I just copied Gnuplot.app into /Applications.

Resources