title: dyld: Library not loaded: @rpath/libopenblas.dylib
body: <p>When I make my file, I have this error:  </p>
  
  <blockquote>
    <p>dyld: Library not loaded: @rpath/libopenblas.dylib     Referenced
    from:   /Users/danyunhe2/reinf_learning2/cpp_original/./navig_test<br>
    Reason: image not found    Abort trap: 6</p>
  </blockquote>
  
  <p>I tried <code>ln -sf &lt;original path&gt; /usr/local/lib</code> but it didn't work.<br>
  From brew info openblas I got:  </p>
  
  <pre><code>openblas: stable 0.3.5 (bottled), HEAD [keg-only]  
  Optimized BLAS library  
  https://www.openblas.net/  
  /usr/local/Cellar/openblas/0.3.5 (22 files, 120.7MB)  
    Poured from bottle on 2019-02-18 at 01:27:14  
  From: https://github.com/Homebrew/homebrew-  core/blob/master/Formula/openblas.rb 
  ==&gt; Dependencies  
  Required: gcc ✔  
  ==&gt; Options  
  --HEAD  
      Install HEAD version  
  ==&gt; Caveats  
  openblas is keg-only, which means it was not symlinked into /usr/local,
  because macOS provides BLAS and LAPACK in the Accelerate framework.  
  
  For compilers to find openblas you may need to set:  
    export LDFLAGS="-L/usr/local/opt/openblas/lib"  
    export CPPFLAGS="-I/usr/local/opt/openblas/include"  
  </code></pre>
  
  <p>It told me to set compiler with LDFLAGS and CPPFLAGS. I tried but it didn't work. Anyone know how to deal with this?   </p>
  
  <p>I have my config.mk as: </p>
  
  <pre><code># C++ compiler
  cxx=g++-7 -fopenmp 
  
  # Compilation flags
  cflags=-Wall -ansi -pedantic -O3 
  
  # BLAS/LAPACK flags for linear algebra
  lp_lflags=-framework Accelerate 
  
  
  # FFTW flags (installed via Homebrew)
  fftw_iflags=
  fftw_lflags=-lfftw3
  
  # libpng flags (installed via Homebrew)
  png_iflags=
  png_lflags=-lpng
  
  </code></pre>
  
  <p>and Makefile:</p>
  
  <pre><code># Load the common configuration file
  include config.mk
  
  iflags=`gsl-config --cflags`
  lflags=`gsl-config --libs`
  
  objs=navigate.o reinf_learn.o common.o
  src=$(patsubst %.o,%.cc,$(objs))
  execs=navig_test
  
  all:
      $(MAKE) executables
  
  executables: $(execs)
  
  depend: $(src)
      $(cxx) $(iflags) -MM $(src) &gt;Makefile.dep
  
  -include Makefile.dep
  
  navig_test: navig_test.cc $(objs)
      $(cxx) $(cflags) $(iflags)  -o $@ $^ $(lflags)
  
  %.o: %.cc
      $(cxx) $(cflags) $(iflags)  -c $&lt;
  
  clean:
      rm -f $(execs) $(objs)
  
  .PHONY: clean all executables depend
  </code></pre>