title: Anaconda on Windows10 : how to call C/C++ from python?
body: <p>I have installed anaconda on windows 10 to get a working python (3.8.3) environnement.</p>
  <p>I try to understand if it's possible to call C/C++ from python with <code>boost-python</code> in this specific setup (anaconda + W10).</p>
  <p>I installed <code>boost</code> with <code>conda install boost</code>.
  I have a hello world example :</p>
  <pre><code>~&gt; more .\hello.cpp
  char const* greet()
  {
         return &quot;hello, world&quot;;
  }
  
  #include &lt;boost/python/python.hpp&gt;
  BOOST_PYTHON_MODULE(hello_bp)
  {
          using namespace boost::python;
              def(&quot;greet&quot;, greet);
  }
  </code></pre>
  <p>Now I run this command line in an anaconda prompt :</p>
  <pre><code>~&gt; g++ -std=c++11 -o hello.so -shared -fPIC -I C:\App\Anaconda3\include -I C:\App\Anaconda3\Library\include hello.cpp -L C:\App\Anaconda3\Library\lib -lboost_python
  ...
  C:\Users\...\AppData\Local\Temp\ccRcsfsi.o:hello.cpp:(.text$_ZN5boost6python9converter23expected_pytype_for_argIPKcE10get_pytypeEv[__ZN5boost6python9converter23expected_pytype_for_argIPKcE10get_pytypeEv]+0x33): undefined reference to `_imp___ZNK5boost6python9converter12registration25expected_from_python_typeEv'
  collect2.exe: error: ld returned 1 exit status
  </code></pre>
  <p>Is it possible to call C/C++ using <code>boost</code> from anaconda on W10 ? Or is this not supported ?</p>
  <p><strong>UPDATE</strong></p>
  <p>A bit more of google-fu (add <code>boost_system</code> and set <code>BOOST_PYTHON_STATIC_LIB</code>) gives</p>
  <pre><code>~&gt; g++ -std=c++11 -o hello.so -shared -fPIC -DBOOST_PYTHON_STATIC_LIB=1 -I C:\App\Anaconda3\include -I C:\App\Anaconda3\Library\include hello.cpp -L C:\App\Anacond
  a3 -L C:\App\Anaconda3\Lib -L C:\App\Anaconda3\Library\lib -lboost_python -lboost_system
  ...
  C:\Users\...\AppData\Local\Temp\cctecCB0.o:hello.cpp:(.text$_ZN5boost6python9converter23expected_pytype_for_argIPKcE10get_pytypeEv[__ZN5boost6python9converter23expected_pytype_for_argIPKcE10get_pytypeEv]+0x31): undefined reference to `boost::python::converter::registration::expected_from_python_type() const'
  collect2.exe: error: ld returned 1 exit status
  </code></pre>
  <p>Do this does not work either...</p>
  <p><strong>UPDATE</strong></p>
  <p>Last unsuccessfull try</p>
  <pre><code>~&gt; g++ -shared -fPIC -DBOOST_PYTHON_STATIC_LIB=1 -DPY_MAJOR_VERSION=3 -DPY_MINOR_VERSION=8 -I C:\App\Anaconda3\include -I C:\App\Anaconda3\Library\include -I C:\App\Anaconda3\Library\include\boost hello.cpp -L C:\App\Anaconda3\libs -L C:\App\Anaconda3\Library\lib -lboost_python38 -lboost_system -lpython38 -o hello.so
  ...
  C:\Users\...\AppData\Local\Temp\ccNhQFY4.o:hello.cpp:(.text+0x3b): undefined reference to `_imp___Py_Dealloc'
  C:\Users\...\AppData\Local\Temp\ccNhQFY4.o:hello.cpp:(.text+0xc7): undefined reference to `boost::python::detail::init_module(PyModuleDef&amp;, void (*)())'
  C:\Users\...\AppData\Local\Temp\ccNhQFY4.o:hello.cpp:(.text$_ZNK5boost6python9type_info4nameEv[__ZNK5boost6python9type_info4nameEv]+0x18): undefined reference to `boost::python::detail::gcc_demangle(char const*)'
  C:\Users\...\AppData\Local\Temp\ccNhQFY4.o:hello.cpp:(.text$_ZNK5boost6python15to_python_valueIRKPKcEclES5_[__ZNK5boost6python15to_python_valueIRKPKcEclES5_]+0x12): undefined reference to `boost::python::converter::do_return_to_python(char const*)'
  C:\Users\...\AppData\Local\Temp\ccNhQFY4.o:hello.cpp:(.text$_ZNK5boost6python15to_python_valueIRKPKcE10get_pytypeEv[__ZNK5boost6python15to_python_valueIRKPKcE10get_pytypeEv]+0xa): undefined reference to `_imp__PyUnicode_Type'
  ...
  C:\Users\...\AppData\Local\Temp\ccNhQFY4.o:hello.cpp:(.text$_ZN5boost6python9converter23expected_pytype_for_argIPKcE10get_pytypeEv[__ZN5boost6python9converter23expected_pytype_for_argIPKcE10get_pytypeEv]+0x31): undefined reference to `boost::python::converter::registration::expected_from_python_type() const'
  collect2.exe: error: ld returned 1 exit status
  </code></pre>
  <p><strong>UPDATE</strong></p>
  <p>Try using <code>cmake</code> yet again without success...</p>
  <pre><code>~&gt; conda install cmake
  ~&gt; git clone https://github.com/TNG/boost-python-examples
  ~&gt; cd boost-python-examples\01-HelloWorld\
  ~&gt; mkdir BUILD
  ~&gt; cd BUILD
  </code></pre>
  <p>A few modification needed in hello world example :</p>
  <pre><code>~&gt; git diff
  diff --git a/01-HelloWorld/CMakeLists.txt b/01-HelloWorld/CMakeLists.txt
  index 66af19c..1d4f3ab 100644
  --- a/01-HelloWorld/CMakeLists.txt
  +++ b/01-HelloWorld/CMakeLists.txt
  @@ -1,4 +1,8 @@
  +CMAKE_MINIMUM_REQUIRED(VERSION 3.18)
  
  +FIND_PACKAGE(Boost 1.73 REQUIRED COMPONENTS python)
  +
  +PROJECT(hello)
   PYTHON_ADD_MODULE(hello hello.cpp)
   FILE(COPY hello.py DESTINATION .)
   ADD_TEST(NAME 01-HelloWorld COMMAND ${PYTHON_EXECUTABLE} hello.py)
  diff --git a/01-HelloWorld/hello.cpp b/01-HelloWorld/hello.cpp
  index 2e2315a..8955462 100644
  --- a/01-HelloWorld/hello.cpp
  +++ b/01-HelloWorld/hello.cpp
  @@ -3,7 +3,7 @@ char const* greet()
      return &quot;hello, world&quot;;
   }
  
  -#include &lt;boost/python.hpp&gt;
  +#include &lt;boost/python/python.hpp&gt;
  
   BOOST_PYTHON_MODULE(hello)
  </code></pre>
  <p>Is it possible to use <code>boost-python</code> installed by <code>conda install boost</code> on windows 10 ? Has this been tested / used ? Any specific tutorial ? (this is just fine on debian...)</p>
  <pre><code>~\boost-python-examples\01-HelloWorld\BUILD&gt; cmake ..
  CMake Error at C:/App/Anaconda3/Library/lib/cmake/Boost-1.73.0/BoostConfig.cmake:141 (find_package):
    Could not find a package configuration file provided by boost_python
    (requested version 1.73.0) with any of the following names:
  
      boost_pythonConfig.cmake
      boost_python-config.cmake
  
    Add the installation prefix of boost_python to CMAKE_PREFIX_PATH or set
    boost_python_DIR to a directory containing one of the above files.  If
    boost_python provides a separate development package or SDK, be sure it
    has been installed.
  
  ~\boost-python-examples\01-HelloWorld\BUILD&gt; cmake  -DCMAKE_PREFIX_PATH=C:\App\Anaconda3\Library\lib\cmake\cmake\boost_python-1.73.0 ..
  -- Building for: Visual Studio 16 2019
  CMake Error at C:/App/Anaconda3/Library/lib/cmake/cmake/BoostDetectToolset-1.73.0.cmake:5 (string):
    string sub-command REGEX, mode MATCHALL needs at least 5 arguments total to
    command.
  Call Stack (most recent call first):
    C:/App/Anaconda3/Library/lib/cmake/cmake/boost_python-1.73.0/boost_python-config.cmake:27 (include)
    C:/App/Anaconda3/Library/lib/cmake/Boost-1.73.0/BoostConfig.cmake:141 (find_package)
    C:/App/Anaconda3/Library/lib/cmake/Boost-1.73.0/BoostConfig.cmake:258 (boost_find_component)
    C:/App/Anaconda3/Library/share/cmake-3.18/Modules/FindBoost.cmake:448 (find_package)
    CMakeLists.txt:3 (FIND_PACKAGE)
  
  
  -- Boost toolset is unknown (compiler  )
  -- Found Boost: C:/App/Anaconda3/Library/lib/cmake/Boost-1.73.0/BoostConfig.cmake (found suitable version &quot;1.73.0&quot;, minimum required is &quot;1.73&quot;) found components: python
  -- Selecting Windows SDK version 10.0.18362.0 to target Windows 10.0.15063.
  -- The C compiler identification is MSVC 19.28.29333.0
  -- The CXX compiler identification is MSVC 19.28.29333.0
  -- Detecting C compiler ABI info
  -- Detecting C compiler ABI info - done
  -- Check for working C compiler: C:/Program Files (x86)/Microsoft Visual Studio/2019/Community/VC/Tools/MSVC/14.28.29333/bin/Hostx64/x64/cl.exe - skipped
  -- Detecting C compile features
  -- Detecting C compile features - done
  -- Detecting CXX compiler ABI info
  -- Detecting CXX compiler ABI info - done
  -- Check for working CXX compiler: C:/Program Files (x86)/Microsoft Visual Studio/2019/Community/VC/Tools/MSVC/14.28.29333/bin/Hostx64/x64/cl.exe - skipped
  -- Detecting CXX compile features
  -- Detecting CXX compile features - done
  CMake Error at CMakeLists.txt:6 (PYTHON_ADD_MODULE):
    Unknown CMake command &quot;PYTHON_ADD_MODULE&quot;.
  
  ```
  
  </code></pre>