Installing Delve on OS X / macOS fails

While trying to debug Go scripts with Visual Studio, I stumbled upon issues configuring Delve on macOS. Delve is a full featured debugging tool for the Go programming language and Visual Studio Code seems to make us of it. Unfortunately the installation might not be as straightforward as described in the official installation documentation. The Brew installation fails while / after generating certificates:

==> Installing delve from go-delve/delve
==> Downloading https://github.com/derekparker/delve/archive/v1.0.0-rc.2.tar.gz
Already downloaded: /Users/beematik/Library/Caches/Homebrew/delve-1.0.0-rc.2.tar.gz
security: SecKeychainSearchCopyNext: The specified item could not be found in the keychain.
==> Generating dlv-cert
==> openssl req -new -newkey rsa:2048 -x509 -days 3650 -nodes -config dlv-cert.cfg -extensions codesign_reqext -batch -out dlv-cert.c
==> [SUDO] Installing dlv-cert as root
==> sudo security add-trusted-cert -d -r trustRoot -k /Library/Keychains/System.keychain dlv-cert.cer
Last 15 lines from /Users/[...]/Library/Logs/Homebrew/delve/02.sudo:
2017-12-31 11:52:35 +0100

sudo
security
add-trusted-cert
-d
-r
trustRoot
-k
/Library/Keychains/System.keychain
dlv-cert.cer


If reporting this issue please do so at (not Homebrew/brew or Homebrew/core):
https://github.com/go-delve/homebrew-delve/issues

These open issues may also help:
Upgrade to delve fails https://github.com/go-delve/homebrew-delve/issues/20

Whatever the reason of this issue might be, there is a suitable workaround available:

cd $HOME/Library/Caches/Homebrew
tar xf delve-*.gz
cd delve-*
sh scripts/gencert.sh
# Type in your sudo password
brew install go-delve/delve/delve

References

  • https://github.com/derekparker/delve/blob/master/Documentation/installation/osx/install.md
  • https://github.com/go-delve/homebrew-delve/issues/19#issuecomment-330442033

Affected System

  • OS X El Capitan 10.11.6
  • Homebrew 1.4.1
  • Delve 1.0.0-rc.2

Building OpenCL on macOS: CL/cl.h not found

Compiling a third party project on macOS, I stumbled upon the following compilation error after running make:

Scanning dependencies of target[...]
[ 33%] Building CXX object CMakeFiles/[...].dir/main.cpp.o
In file included from /Users/[...]/main.cpp:11:
/Users/[...]/CLCalculator.h:14:10: fatal error: 'CL/cl.h' file not found
#include <CL/cl.h>
         ^
1 error generated.
make[2]: *** [CMakeFiles/[...].dir/main.cpp.o] Error 1
make[1]: *** [CMakeFiles/[...].dir/all] Error 2
make: *** [all] Error 2

Unfortunately the application was originally not intended for macOS / OS X platforms. There are quite some examples of similar encounters in the vastness of the internet. But… there is a simple way to make your the respective code cross-plattform and compatible with macOS / OS X:

#if defined(__APPLE__) || defined(__MACOSX)
#include <OpenCL/cl.h>
#else
#include <CL/cl.h>
#endif

Just replace the #include <CL/cl.h> statement with the snippet above and run make again – great…