title: Boost.Python Link Error with Python3 and virtualenv
body: <p>I got the following error when I tried to compile <code>.cpp</code> file with <code>clang++</code>.</p>
  
  <pre><code>ld: symbol(s) not found for architecture x86_64
  clang: error: linker command failed with exit code 1 (use -v to see invocation)
  </code></pre>
  
  <hr>
  
  <p>I set up <code>Python</code> and <code>boost-python</code> as follows.</p>
  
  <p><strong>Python</strong></p>
  
  <p>I installed Python 3.6.0 using <code>pyenv-virtualenv</code> (via <code>homebrew</code>)</p>
  
  <p><strong>Boost-Python</strong></p>
  
  <p>I used <code>homebrew</code> in Python 3 environment.</p>
  
  <pre><code>$ source activate py36    
  $ brew install boost-python --with-python3 --without-python
  </code></pre>
  
  <p><strong>~/.bash_profile</strong></p>
  
  <p>My <code>~/.bash_profile</code> looks like this:</p>
  
  <pre><code>export PYENV_ROOT="/usr/local/var/pyenv"
  export PYENV_VIRTUALENV_DISABLE_PROMPT=1
  export CPLUS_INCLUDE_PATH="$CPLUS_INCLUDE_PATH:/usr/local/var/pyenv/versions/3.6.0/include/python3.6m/"
  if which pyenv &gt; /dev/null; then eval "$(pyenv init -)"; fi
  if which pyenv-virtualenv-init &gt; /dev/null; then eval "$(pyenv virtualenv-init -)" ; fi
  </code></pre>
  
  <hr>
  
  <p><strong>Test cpp</strong></p>
  
  <p>This is the file I tried to compile and failed (saved as <code>test.cpp</code>).</p>
  
  <pre><code>#define BOOST_PYTHON_STATIC_LIB    
  #include &lt;boost/python.hpp&gt;
  using namespace boost::python;
  
  char const* say(){
    return "hello, world";
  }
  
  
  BOOST_PYTHON_MODULE( hello ){
  
    boost::python::def( "say", say );
  
  }
  </code></pre>
  
  <hr>
  
  <p><strong>makefile</strong></p>
  
  <pre><code>CC = clang++
  INCLUDE = -I`python -c 'from distutils.sysconfig import *; print(get_python_inc())’`
  BOOST = -lboost_python3.6 -lboost_serialization
  FMATH =  -fomit-frame-pointer -fno-operator-names -msse2 -mfpmath=sse -march=native
  CFLAGS = -std=c++11 -L/usr/local/lib -O3
  CFLAGS_SO = -shared -fPIC -std=c++11 -L/usr/local/lib -O3 
  LINK = -L/usr/local/Cellar/boost-python/1.64.0/lib/
  
  install: 
      $(CC) test.cpp -o hello.so $(INCLUDE) $(BOOST) $(LINK) $(FMATH) $(CFLAGS_SO)
  </code></pre>
  
  <hr>
  
  <p><strong>Error</strong></p>
  
  <p><code>make install</code> returns this error.</p>
  
  <pre><code>clang++ test.cpp -o hello.so -I`python -c 'from distutils.sysconfig import *; print(get_python_inc())’` -lboost_python3.6 -lboost_serialization -L/usr/local/Cellar/boost-python/1.64.0/lib/ -fomit-frame-pointer -fno-operator-names -msse2 -mfpmath=sse -march=native -shared -fPIC -std=c++11 -L/usr/local/lib -O3  -v
  /bin/sh: command substitution: line 0: unexpected EOF while looking for matching `''
  /bin/sh: command substitution: line 1: syntax error: unexpected end of file
  Apple LLVM version 8.1.0 (clang-802.0.42)
  Target: x86_64-apple-darwin16.6.0
  Thread model: posix
  InstalledDir: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin
  clang -cc1 version 8.1.0 (clang-802.0.42) default target x86_64-apple-darwin16.6.0
  ignoring nonexistent directory "-lboost_python3.6"
  ignoring nonexistent directory "/usr/include/c++/v1"
  #include "..." search starts here:
  #include &lt;...&gt; search starts here:
   .
   /usr/local/var/pyenv/versions/3.6.0/include/python3.6m
   /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1
   /usr/local/include
   /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../lib/clang/8.1.0/include
   /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include
   /usr/include
   /System/Library/Frameworks (framework directory)
   /Library/Frameworks (framework directory)
  End of search list.
   "/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ld" -demangle -lto_library /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/libLTO.dylib -dynamic -dylib -arch x86_64 -macosx_version_min 10.12.0 -o hello.so -L/usr/local/Cellar/boost-python/1.64.0/lib/ -L/usr/local/lib /var/folders/rm/qv81g4ss29j_gv1b366rl2080000gp/T/test-16790a.o -lboost_serialization -lc++ -lSystem /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../lib/clang/8.1.0/lib/darwin/libclang_rt.osx.a
  Undefined symbols for architecture x86_64:
  
  &lt;LINES ARE OMITTED&gt;
  
  ld: symbol(s) not found for architecture x86_64
  clang: error: linker command failed with exit code 1 (use -v to see invocation)
  make: *** [install] Error 1
  </code></pre>