[Boost-bugs] [Boost C++ Libraries] #13062: LNK2019 Unresolved External Symbol in VS2015 when using Boost python3 and numpy3 libraries on Windows

Subject: [Boost-bugs] [Boost C++ Libraries] #13062: LNK2019 Unresolved External Symbol in VS2015 when using Boost python3 and numpy3 libraries on Windows
From: Boost C++ Libraries (noreply_at_[hidden])
Date: 2017-06-09 10:03:35


#13062: LNK2019 Unresolved External Symbol in VS2015 when using Boost python3 and
numpy3 libraries on Windows
------------------------------+-------------------------------
 Reporter: oystein@… | Owner: rwgk
     Type: Bugs | Status: new
Milestone: To Be Determined | Component: python USE GITHUB
  Version: Boost 1.64.0 | Severity: Showstopper
 Keywords: python3 numpy3 |
------------------------------+-------------------------------
 I am getting linker errors when trying to use the numpy3 library on
 Windows:

 {{{
 test_boost_python.obj : error LNK2019: unresolved external symbol "class
 boost::python::numpy::dtype __cdecl
 boost::python::numpy::detail::get_float_dtype<32>(void)"
 (??$get_float_dtype@$0CA@@detail_at_numpy@python_at_boost@@YA?AVdtype_at_123@XZ)
 referenced in function "public: static class boost::python::numpy::dtype
 __cdecl boost::python::numpy::detail::builtin_dtype<float,0>::get(void)"
 (?get@?$builtin_dtype_at_M$0A@@detail_at_numpy@python_at_boost@@SA?AVdtype_at_345@XZ)
 }}}

 Small test program to reproduce:

 {{{#!c++
 #include <boost/python.hpp>
 #include <boost/python/numpy.hpp>

 namespace bp = boost::python;
 namespace np = boost::python::numpy;

 np::ndarray test_make_zeros(int rows, int cols)
 {
     return np::zeros(bp::make_tuple(rows, cols),
 np::dtype::get_builtin<float>());
 }

 BOOST_PYTHON_MODULE(test_boost_numpy)
 {
     np::initialize();

     bp::def("test_make_zeros", test_make_zeros);
 }
 }}}

 I have downloaded and built Boost 1.64 on Windows by using the following
 command:

 {{{
 b2 --build-type=complete address-model=64 toolset=msvc stage
 }}}

 I added a user-config.jam file in my home directory to tell Boost where to
 find Python 3:

 {{{
 using python : 3.6 : c:\\anaconda3\\python ;
 }}}

 I am using the following CMakeLists.txt file:

 {{{
 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})
 }}}

 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.

 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?)

 See also https://stackoverflow.com/questions/44072440/lnk2019-unresolved-
 external-symbol-in-vs2015-when-using-boost-python3-and-numpy3 for more
 information

--
Ticket URL: <https://svn.boost.org/trac10/boost/ticket/13062>
Boost C++ Libraries <http://www.boost.org/>
Boost provides free peer-reviewed portable C++ source libraries.

This archive was generated by hypermail 2.1.7 : 2017-06-09 10:06:32 UTC