Boost C++ Libraries: Ticket #13062: LNK2019 Unresolved External Symbol in VS2015 when using Boost python3 and numpy3 libraries on Windows https://svn.boost.org/trac10/ticket/13062 <p> I am getting linker errors when trying to use the numpy3 library on Windows: </p> <pre class="wiki">test_boost_python.obj : error LNK2019: unresolved external symbol "class boost::python::numpy::dtype __cdecl boost::python::numpy::detail::get_float_dtype&lt;32&gt;(void)" (??$get_float_dtype@$0CA@@detail@numpy@python@boost@@YA?AVdtype@123@XZ) referenced in function "public: static class boost::python::numpy::dtype __cdecl boost::python::numpy::detail::builtin_dtype&lt;float,0&gt;::get(void)" (?get@?$builtin_dtype@M$0A@@detail@numpy@python@boost@@SA?AVdtype@345@XZ) </pre><p> Small test program to reproduce: </p> <div class="wiki-code"><div class="code"><pre><span class="cp">#include</span> <span class="cpf">&lt;boost/python.hpp&gt;</span><span class="cp"></span> <span class="cp">#include</span> <span class="cpf">&lt;boost/python/numpy.hpp&gt;</span><span class="cp"></span> <span class="k">namespace</span> <span class="n">bp</span> <span class="o">=</span> <span class="n">boost</span><span class="o">::</span><span class="n">python</span><span class="p">;</span> <span class="k">namespace</span> <span class="n">np</span> <span class="o">=</span> <span class="n">boost</span><span class="o">::</span><span class="n">python</span><span class="o">::</span><span class="n">numpy</span><span class="p">;</span> <span class="n">np</span><span class="o">::</span><span class="n">ndarray</span> <span class="n">test_make_zeros</span><span class="p">(</span><span class="kt">int</span> <span class="n">rows</span><span class="p">,</span> <span class="kt">int</span> <span class="n">cols</span><span class="p">)</span> <span class="p">{</span> <span class="k">return</span> <span class="n">np</span><span class="o">::</span><span class="n">zeros</span><span class="p">(</span><span class="n">bp</span><span class="o">::</span><span class="n">make_tuple</span><span class="p">(</span><span class="n">rows</span><span class="p">,</span> <span class="n">cols</span><span class="p">),</span> <span class="n">np</span><span class="o">::</span><span class="n">dtype</span><span class="o">::</span><span class="n">get_builtin</span><span class="o">&lt;</span><span class="kt">float</span><span class="o">&gt;</span><span class="p">());</span> <span class="p">}</span> <span class="n">BOOST_PYTHON_MODULE</span><span class="p">(</span><span class="n">test_boost_numpy</span><span class="p">)</span> <span class="p">{</span> <span class="n">np</span><span class="o">::</span><span class="n">initialize</span><span class="p">();</span> <span class="n">bp</span><span class="o">::</span><span class="n">def</span><span class="p">(</span><span class="s">&quot;test_make_zeros&quot;</span><span class="p">,</span> <span class="n">test_make_zeros</span><span class="p">);</span> <span class="p">}</span> </pre></div></div><p> I have downloaded and built Boost 1.64 on Windows by using the following command: </p> <pre class="wiki">b2 --build-type=complete address-model=64 toolset=msvc stage </pre><p> I added a user-config.jam file in my home directory to tell Boost where to find Python 3: </p> <pre class="wiki">using python : 3.6 : c:\\anaconda3\\python ; </pre><p> I am using the following CMakeLists.txt file: </p> <pre class="wiki">cmake_minimum_required(VERSION 3.8) project(test_boost_python) set(BOOST_ROOT "C:/Boost-1.64") SET(Boost_ADDITIONAL_VERSIONS 1.64) find_package(PythonLibs 3.6 REQUIRED) include_directories(${PYTHON_INCLUDE_DIRS}) find_package(Boost REQUIRED COMPONENTS python3 numpy3) include_directories(${Boost_INCLUDE_DIRS}) link_directories(${Boost_LIBRARY_DIRS}) add_library(test_boost_python SHARED test_boost_python.cpp) set_target_properties(test_boost_python PROPERTIES PREFIX "" SUFFIX ".pyd") set_target_properties(test_boost_python PROPERTIES DEFINE_SYMBOL "BOOST_ALL_NO_LIB") target_link_libraries(test_boost_python ${PYTHON_LIBRARIES} ${Boost_LIBRARIES}) </pre><p> My boost::python library is given the name boost_python3-vc140-mt-1_64.lib and boost::numpy ends up as boost_numpy3-vc140-mt-1_64.lib when linking against Python 3.6. </p> <p> I had to turn on BOOST_ALL_NO_LIB. If not, the compiler looks for boost_python-vc140-mt-1_64.lib boost_numpy-vc140-mt-1_64.lib (which is under the wrong name, with a missing number 3 after the library names; possibly also a bug on Windows?) </p> <p> See also <a class="ext-link" href="https://stackoverflow.com/questions/44072440/lnk2019-unresolved-external-symbol-in-vs2015-when-using-boost-python3-and-numpy3"><span class="icon">​</span>https://stackoverflow.com/questions/44072440/lnk2019-unresolved-external-symbol-in-vs2015-when-using-boost-python3-and-numpy3</a> for more information </p> en-us Boost C++ Libraries /htdocs/site/boost.png https://svn.boost.org/trac10/ticket/13062 Trac 1.4.3